Home
MCQS
Python MCQ Quiz Hub
Python MCQs
Choose a topic to test your knowledge and improve your Python skills
1. What is the maximum possible length of an identifier?
16
32
64
None of these above
2. Who developed the Python language?
Zim Den
Guido van Rossum
Niene Stom
Wick van Rossum
3. In which year was the Python language developed?
1995
1972
1981
1989
4. In which language is Python written?
English
PHP
C
All of the above
5. Which one of the following is the correct extension of the Python file?
.py
.python
.p
None of these
6. In which year was the Python 3.0 version developed?
2008
2000
2010
2005
7. What do we use to define a block of code in Python language?
Key
Brackets
Indentation
None of these
8. Which character is used in Python to make a single line comment?
/
//
#
!
9. Which of the following statements is correct regarding the object-oriented programming concept in Python?
Classes are real-world entities while objects are not real
Objects are real-world entities while classes are not real
Both objects and classes are real-world entities
All of the above
10. Which of the following statements is correct in this python code? class Name: def __init__(javatpoint): javajavatpoint = java name1=Name("ABC") name2=name1
It will throw the error as multiple references to the same object is not possible
id(name1) and id(name2) will have same value
Both name1 and name2 will have reference to two different objects of class Name
All of the above
11. What is the method inside the class in python language?
Object
Function
Attribute
Argument
12. Which of the following declarations is incorrect?
_x = 2
__x = 3
__xyz__ = 5
None of these
13. Why does the name of local variables start with an underscore discouraged?
To identify the variable
It confuses the interpreter
It indicates a private variable of a class
None of these
14. Which of the following is not a keyword in Python language?
val
raise
try
with
15. Which of the following statements is correct for variable names in Python language?
All variable names must begin with an underscore.
Unlimited length
The variable name length is a maximum of 2.
All of the above
16. Which of the following declarations is incorrect in python language?
xyzp = 5,000,000
x y z p = 5000 6000 7000 8000
x,y,z,p = 5000, 6000, 7000, 8000
x_y_z_p = 5,000,000
17. Which of the following words cannot be a variable in python language?
_val
val
try
_try_
18. Which of the following operators is the correct option for power(ab)?
a ^ b
a**b
a ^ ^ b
a ^ * b
19. Which of the following precedence order is correct in Python?
Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Multiplication, Division, Addition, Subtraction, Parentheses, Exponential
Division, Multiplication, Addition, Subtraction, Parentheses, Exponential
Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
20. Which one of the following has the same precedence level?
Division, Power, Multiplication, Addition and Subtraction
Division and Multiplication
Subtraction and Division
Power and Division
21. Which one of the following has the highest precedence in the expression?
Division
Subtraction
Power
Parentheses
22. Which of the following functions is a built-in function in python language?
val()
print()
print()
None of these
23. Study the following function:round(4.576) What will be the output of this function?
4
5
576
5
24. Which of the following is correctly evaluated for this function? pow(x,y,z)
(x**y) / z
(x / y) * z
(x**y) % z
(x / y) / z
25. Study the following function: all([2,4,0,6]) What will be the output of this function?
False
TRUE
0
Invalid code
26. Study the following program: x = 1 while True: if x % 5 = = 0: break print(x) x + = 1 What will be the output of this code?
error
2 1
0 3 1
None of these
27. Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:java.txt''?
Infile = open(''d:\java.txt'', ''r'')
Infile = open(file=''d:\java.txt'', ''r'')
Infile = open(''d:java.txt'',''r'')
Infile = open.file(''d:\java.txt'',''r'')
28. Study the following code: x = ['XX', 'YY'] for i in a: i.lower() print(a) What will be the output of this program?
['XX', 'YY']
['xx', 'yy']
[XX, yy]
None of these
29. Study the following function: import math abs(math.sqrt(36)) What will be the output of this code?
Error
#VALUE!
6
6
30. Study the following function:any([5>8, 6>3, 3>1]) What will be the output of this code?
FALSE
True
Invalid code
None of these
31. Study the following statement: >>>"a"+"bc" What will be the output of this statement?
a+bc
abc
a bc
a
32. Study the following code: >>>"javatpoint"[5:] What will be the output of this code?
javatpoint
java
point
None of these
33. The output to execute string.ascii_letters can also be obtained from:?
character
ascii_lowercase_string.digits
lowercase_string.upercase
ascii_lowercase+string.ascii_upercase
34. Study the following statements: >>> str1 = "javat" >>> str2 = ":" >>> str3 = "point" >>> str1[-1:] What will be the output of this statement?
t
j
point
Java
35. Study the following statements: >>> print(0xA + 0xB + 0xC) What will be the output of this statement?
33
63
0xA + 0xB + 0xC
None of these
36. Study the following statements: >>> print(ord('h') - ord('z')) What will be the output of this statement?
18
-18
17
-17
37. Study the following program: x = ['xy', 'yz'] for i in a: i.upper() print(a) Which of the following is correct output of this program?
['xy', 'yz']
['XY', 'YZ']
[None, None]
None of these
38. Study the following program: i = 1: while True: if i%3 == 0: break print(i) Which of the following is the correct output of this program?
1 2 3
3 2 1
1 2
Invalid syntax
39. Study the following program: a = 1 while True: if a % 7 = = 0: break print(a) a += 1 Which of the following is correct output of this program?
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
Invalid syntax
40. Study the following program: i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) What will be the output of this statement?
1 2 3
0 1 2 3
0 1 2
3 2 1
41. Which keyword is use for function?
define
fun
def
function
42. Which of the following items are present in the function header?
function name
parameter list
return value
Both A and B
43. What is called when a function is defined inside a class?
class
function
method
module
44. If return statement is not used inside the function, the function will return:
None
0
Null
Arbitary value
45. What is a recursive function?
A function that calls other function.
A function which calls itself.
Both A and B
None of the above
46. Which of the following is the use of id() function in python?
Id() returns the size of object.
Id() returns the identity of the object.
Both A and B
None of the above
47. Which of the following function headers is correct?
def fun(a = 2, b = 3, c)
def fun(a = 2, b, c = 3)
def fun(a, b = 2, c = 3)
def fun(a, b, c = 3, d)
48. In which part of memory does the system stores the parameter and local variables of funtion call?
heap
stack
Uninitialized data segment
None of the above
49. How is a function declared in Python?
def function function_name():
declare function function_name():
def function_name():
declare function_name():
50. Which one of the following is the correct way of calling a function?
function_name()
call function_name()
ret function_name()
function function_name()
51. Which operator is used in Python to import modules from packages?
.
*
-&gt;
&amp;
52. Where is function defined?
Module
class
Another Function
All of the above
53. Lambda is a function in python?
TRUE
FALSE
Lambda is a function in python but user can not use it.
None of the above
54. What is a variable defined outside a function referred to as?
local variable
global variable
static Variable
automatic variable
55. What is the output of the following program?z = lambda x : x * x print(z(6))
6
36
0
error
56. What is the output of the following program? print(chr(ord(chr(97))))
a
A
97
error
57. Which one of the following is incorrect?
The variables used inside function are called local variables.
The local variables of a particular function can be used inside other functions, but these cannot be used in global space
The variables used outside function are called global variables
In order to change the value of global variable inside function, keyword global is used.
Submit