Q: What will be the output of the following Python code? >>>str="hello" >>>str[:2] >>>
Solution: We are printing only the 1st two bytes of string and hence the answer is “he”.
Q: Given a function that does not return any value, What value is thrown by default when executed in shell.
Solution: Python shell throws a NoneType object back.
Q: Which of these in not a core data type?
Solution: Class is a user defined data type.
Q: Which of the following will run without errors?
Solution: Execute help(round) in the shell to get details of the parameters that are passed into the round function.
Q: What is the return type of function id?
Solution: Execute help(id) to find out details in python shell.id returns a integer value that is unique.
Q: In python we do not specify types, it is directly interpreted by the compiler, so consider the following operation to be performed. >>>x = 13 ? 2 objective is to make sure x has a integer value, select all that apply (python 3.xx)
Solution: // is integer operation in python 3.0 and int(..) is a type cast operator.
Q: What error occurs when you execute the following Python code snippet? apple = mango
Solution: Mango is not defined hence name error.
Q: In order to store values in terms of key and value we use what core data type.
Solution: Dictionary stores values in terms of keys and values.
You Have Score    | /8 |