Learn Python MCQs
Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of print(type(5))?
1) class 'int'
2) class 'float'
3) class 'str'
4) class 'list'
Answer : <class 'int'>
Which of the following is a mutable data type in Python?
1) List
2) Tuple
3) String
4) Integer
Answer : List
What is the correct file extension for Python files?
1) .py
2) .python
3) .pyt
4) .pt
Answer : .py
How do you create a function in Python?
1) def myFunction():
2) function myFunction():
3) create myFunction():
4) def myFunction[]
Answer : def myFunction():
Which keyword is used to create a class in Python?
1) class
2) create
3) def
4) object
Answer : class
What is the output of 3 * 2 ** 2?
1) 12
2) 9
3) 6
4) 8
Answer : 12
What does the len() function do in Python?
1) Returns the length of an object
2) Returns the size of an object
3) Checks if an object is empty
4) Creates a new list
Answer : Returns the length of an object
How do you insert comments in Python?
1) # This is a comment
2) // This is a comment
3) /* This is a comment */
4) <-- This is a comment
Answer : # This is a comment
Which of the following is not a built-in data type in Python?
1) List
2) Dictionary
3) Set
4) Class
Answer : Class
How do you create a list in Python?
1) myList = []
2) myList = {}
3) myList = ()
4) myList = list()
Answer : myList = []