Home
MCQS
Python MCQ Quiz Hub
Python Mcq Set 1
Choose a topic to test your knowledge and improve your Python skills
1. Is Python case sensitive when dealing with identifiers?
yes
no
machine dependent
none of the mentioned
2. What is the maximum possible length of an identifier?
31 characters
63 characters
79 characters
none of the mentioned
3. Which of the following is invalid?
_a = 1
__a = 1
__str__ = 1
none of the mentioned
4. Which of the following is an invalid variable?
my_string_1
1st_string
foo
_
5. Why are local variable names beginning with an underscore discouraged?
they are used to indicate a private variables of a class
they confuse the interpreter
they are used to indicate global variables
they slow down execution
6. Which of the following is not a keyword?
eval
assert
nonlocal
pass
7. Which is the correct operator for power(xy)?
X^y
X**y
X^^y
none of the mentioned
8. Which one of these is floor division?
/
//
%
none of the mentioned
9. What is the answer to this expression, 22 % 3 is?
7
1
0
5
10. Operators with the same precedence are evaluated in which manner?
Left to Right
Right to Left
Can’t say
none of the mentioned
11. What is the output of this expression, 3*1**3?
27
9
3
1
12. Which of these in not a core data type?
Lists
Dictionary
Tuples
Class
13. Given a function that does not return any value, What value is thrown by default when executed in shell.
int
bool
void
None
14. Which of the following will run without errors?
round(45.8)
round(6352.898,2,5)
round()
round(7463.123,2,1)
15. What is the return type of function id?
int
float
bool
dict
16. 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)
x = 13 // 2
x = int(13 / 2)
x = 13 % 2
all of the mentioned
17. What error occurs when you execute the following Python code snippet? apple = mango
SyntaxError
NameError
ValueError
TypeError
18. What data type is the object below? L = [1, 23, 'hello', 1]
list
dictionary
array
tuple
19. In order to store values in terms of key and value we use what core data type.
list
tuple
class
Dictionary
20. Which of the following results in a SyntaxError?
‘”Once upon a time…”, she said.’
“He said, ‘Yes!'”
‘3’
”’That’s okay”’
21. Select all options that print. hello-how-are-you
print(‘hello’, ‘how’, ‘are’, ‘you’)
print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
print(‘hello-‘ + ‘how-are-you’)
print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
22. What is the return value of trunc()?
int
bool
float
None
23. What is the output of print 0.1 + 0.2 == 0.3?
True
False
Machine dependent
Error
24. Which of the following is not a complex number?
k = 2 + 3j
k = complex(2, 3)
k = 2 + 3l
k = 2 + 3J
25. What is the type of inf?
Boolean
Integer
Float
Complex
26. What does ~4 evaluate to?
-5
-4
-3
+3
27. What does ~~~~~~5 evaluate to?
+5
-11
+11
-5
28. Which of the following is incorrect?
x = 0b101
x = 0x4f5
x = 19023
x = 03964
29. What is the result of cmp(3, 1)?
1
0
True
False
30. Which of the following is incorrect?
float(‘inf’)
float(‘nan’)
float(’56’+’78’)
float(’12+34′)
31. What is the result of round(0.5) – round(-0.5)?
1.0
2.0
0.0
Value depends on Python version
32. What does 3 ^ 4 evaluate to?
81
12
0.75
7
33. What will be the value of the following Python expression? 4 + 3 % 5
4
7
2
0
34. Evaluate the expression given below if A = 16 and B = 15. A % B // A
0.0
0
1.0
1
35. Which of the following operators has its associativity from right to left?
+
//
%
**
36. What will be the value of x in the following Python expression? x = int(43.55+2/2)
43
44
22
23
37. What is the value of the following expression? 2+4.00, 2**4.0
(6.0, 16.0)
(6.00, 16.00)
(6, 16)
(6.00, 16.0)
38. Which of the following is the truncation division operator?
/
%
//
|
39. What are the values of the following Python expressions? 2**(3**2) (2**3)**2 2**3**2
64, 512, 64
64, 64, 64
512, 512, 512
512, 64, 512
40. What is the value of the following expression? 8/4/2, 8/(4/2)
(1.0, 4.0)
(1.0, 1.0)
(4.0. 1.0)
(4.0, 4.0)
41. What is the value of the following expression? float(22//3+3/3)
8
8.0
8.3
8.33
42. What will be the output of the following Python expression? print(4.00/(2.0+2.0))
Error
1.0
1.00
1
43. What will be the value of X in the following Python expression? X = 2+9*((3*12)-8)/10
30.0
30.8
28.4
27.2
44. Which of the following expressions involves coercion when evaluated in Python?
4.7 – 1.5
7.9 * 6.3
1.7 % 2
3.4 + 4.6
45. What will be the output of the following Python expression? 24//6%3, 24//4//2
(1,3)
(0,3)
(1,0)
(3,1)
46. Which among the following list of operators has the highest precedence? +, -, **, %, /, <<, >>, |
&lt;&lt;, &gt;&gt;
**
|
%
47. What will be the value of the following Python expression? float(4+int(2.39)%2)
5.0
5
4.0
4
48. Which of the following expressions is an example of type conversion?
4.0 + float(3)
5.3 + 6.3
5.0 + 3
3 + 7
49. Which of the following expressions results in an error?
float(‘10’)
int(‘10’)
float(’10.8’)
int(’10.8’)
50. What will be the value of the following Python expression? 4+2**5//10
3
7
77
0
Submit