Learn Python MCQs
Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of the sorted() function in Python?
1) Sorts a list
2) Reverses a list
3) Creates a new list
4) Filters a list
Answer : Sorts a list
What is the output of print(3 == 3 and 4 == 4)?
1) True
2) False
3) None
4) Error
Answer : True
How do you declare a global variable in Python?
1) global myVar
2) declare myVar
3) myVar = global
4) myVar::global
Answer : global myVar
What is the output of print("abc".find("b"))?
1) 1
2) 0
3) -1
4) 2
Answer : 1
Which method is used to remove an item from a list in Python?
1) delete()
2) remove()
3) pop()
4) discard()
Answer : remove()
How do you convert a string to an integer in Python?
1) int("string")
2) str("int")
3) convert("string")
4) string.toInt()
Answer : int("string")
What is the output of print([1, 2, 3] * 2)?
1) [1, 2, 3, 1, 2, 3]
2) [2, 4, 6]
3) [1, 2, 3, 2, 4, 6]
4) [1, 2, 3][1, 2, 3]
Answer : [1, 2, 3, 1, 2, 3]
Which of the following is a Python web framework?
1) Flask
2) Django
3) Pyramid
4) All of the above
Answer : All of the above
What is the output of print("Python"[1:4])?
1) yth
2) Pyt
3) Python
4) on
Answer : yth
How do you concatenate two lists in Python?
1) list1 + list2
2) list1.append(list2)
3) list1.extend(list2)
4) Both a and c
Answer : Both a and c