Python MCQ Question
1. Which of these in not a core data type?
a) Lists
b) Dictionary
c) Tuples
d) Class
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
3. Following set of commands are executed in shell, what will be the output?
>>>str="hello"
>>>str[:2]
>>>
a) he
b) lo
c) olleh
d) hello
4. What error occurs when you execute?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
5. What data type is the object below ?
L = *1, 23, ‘hello’, 1+.
a) list
b) dictionary
c) array
d) tuple
6. 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
7. 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”’
8. What is the average value of the code that is executed below ?
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2
a) 85
b) 85.1
c) 95
d) 95.1
9. 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’)
10. Which of the following is not a complex number?
a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J
11. Which of the following is incorrect?
a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964
12. What is the output when following statement is executed ?
>>>"a"+"bc"
a) a
b) bc
c) bca
d) abc
13. What is the output when following statement is executed ?
>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc
14. What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a) olleh
b) hello
c) h
d) o
15. What arithmetic operators cannot be used with strings ?
a) +
b) *
c) –
d) All of the mentioned
16. print(0xA + 0xB + 0xC) :
a) 0xA0xB0xC
b) Error
c) 0x22
d) 33