Q 1. Which of these in not a core data type?
A. Lists
B. Dictionary
C. Tuples
D. Class
Show Answer
Answer:-D. ClassExplanation
Explanation:- Class is a user defined data type.Q 2. Given a function that does not return any value, What value is thrown by default when executed in shell.
A. int
B. bool
C. void
D. None
Show Answer
Answer:-D. NoneExplanation
Explanation:- Python shell throws a NoneType object back.Q 3. What will be the output of the following Python code?
- >>>str=”hello”
- >>>str[:2]
- >>>
A. he
B. lo
C. olleh
D. hello
Show Answer
Answer:-A. heExplanation
Explanation:- We are printing only the 1st two bytes of string and hence the answer is “he”.Q 4. Which of the following will run without errors?
A. round(45.8)
B. round(6352.898,2,5)
C. round()
D. round(7463.123,2,1)
Show Answer
Answer:-A. round(45.8)Explanation
Explanation:- Execute help(round) in the shell to get details of the parameters that are passed into the round function.Q 5. What is the return type of function id?
A. int
B. float
C. bool
D. dict
Show Answer
Answer:-A. intExplanation
Explanation:- Execute help(id) to find out details in python shell.id returns a integer value that is unique.Q 6. 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)
A. x = 13 // 2
B. x = int(13 / 2)
C. x = 13 % 2
D. All of the mentioned
Show Answer
Answer:-D. All of the mentionedExplanation
Explanation:- // is integer operation in python 3.0 and int(..) is a type cast operator.Q 7. What error occurs when you execute the following Python code snippet?
apple = mango
A. SyntaxError
B. NameError
C. ValueError
D. TypeError
Show Answer
Answer:-B. NameErrorExplanation
Explanation:- Mango is not defined hence name error.Q 8. What will be the output of the following Python code snippet?
- def example(a):
- a = a + ‘2’
- a = a*2
- return a
- >>>example(“hello”)
A. indentation Error
B. cannot perform mathematical operation on strings
C. hello2
D. hello2hello2
Show Answer
Answer:-B. cannot perform mathematical operation on stringsExplanation
Explanation:- Python codes have to be indented properly.Q 9. What data type is the object below?
L = [1, 23, 'hello', 1]
A. list
B. dictionary
C. array
D. tuple
Show Answer
Answer:-A. listExplanation
Explanation:- List data type can store any values within it.Q 10. In order to store values in terms of key and value we use what core data type.
A. list
B. tuple
C. class
D. dictionary
Show Answer
Answer:-D. dictionaryExplanation
Explanation:- Dictionary stores values in terms of keys and values.11. Which of the following results in a SyntaxError?
A. ‘”Once upon a time…”, she said.’
B. “He said, ‘Yes!’”
C. ‘3\’
D. ”’That’s okay”’
Show Answer
Answer:-C. ‘3\’Explanation
Explanation:- Carefully look at the colons.Q 12. The following is displayed by a print function call. Select all of the function calls that result in this output.
- tom
- dick
- harry
A.print(”’tom
\ndick
\nharry”’)
B. print(”’tomdickharry”’)
C. print(‘tom\ndick\nharry’)
D. print(‘tom
dick
harry’)
Show Answer
Answer:-C. print(‘tom\ndick\nharry’)Explanation
Explanation:- The \n adds a new line.Q 13. What is the average value of the following Python code snippet?
- >>>grade1 = 80
- >>>grade2 = 90
- >>>average = (grade1 + grade2) / 2
A. 85.0
B. 85.1
C. 95.0
D. 95.1
Show Answer
Answer:-A. 85.0Explanation
Explanation:- Cause a decimal value of 0 to appear as output.Q 14. Select all options that print.
hello-how-are-you
A. print(‘hello’, ‘how’, ‘are’, ‘you’)
B. print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
C. print(‘hello-‘ + ‘how-are-you’)
D. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
Show Answer
Answer:-C. print(‘hello-‘ + ‘how-are-you’)Explanation
Explanation:- Execute in the shell.Q 15. What is the return value of trunc()?
A. int
B. bool
C. float
D. None
Leave a Reply