Python MCQ Set-1

1. What is the output of print(2 ** 3)?
A. 6
B. 8
C. 9
D. 5

2. Which of the following is a valid variable name in Python?
A. 1value
B. value1
C. @value
D. value-1

3. What is the data type of print(type(“Hello”))?
A. int
B. bool
C. str
D. float

4. Which keyword is used for defining a function in Python?
A. func
B. define
C. def
D. function

5. What is the result of 5 // 2?
A. 2.5
B. 2
C. 3
D. 2.0

6. What will print(bool(“”)) return?
A. True
B. False
C. 0
D. Error

7. Which of the following is not a Python data type?
A. list
B. tuple
C. set
D. array

8. How do you insert comments in Python code?
A. //
B. <!– –>
C. #
D. /* */

9. What is the correct file extension for Python files?
A. .pt
B. .pyt
C. .py
D. .python

10. What is the output of print(“Python”[1])?
A. P
B. y
C. t
D. h

11. Which operator is used to check equality?
A. =
B. :=
C. ==
D. !=

12. What is the correct way to create a list in Python?
A. list = (1, 2, 3)
B. list = [1, 2, 3]
C. list = {1, 2, 3}
D. list = <1, 2, 3>

13. Which of these is used to define a block of code in Python?
A. {}
B. ()
C. indentation
D. begin-end

14. What is the output of print(10 % 3)?
A. 1
B. 0
C. 3
D. 10

15. Python is a:
A. Low-level language
B. High-level language
C. Machine language
D. None of the above

16. What does len() function return for len([1, 2, 3, 4])?
A. 3
B. 4
C. 5
D. Error

17. Which of the following is a Python tuple?
A. [1, 2, 3]
B. {1, 2, 3}
C. (1, 2, 3)
D. <1, 2, 3>

18. Which symbol is used for exponentiation in Python?
A. ^
B. **
C. ^^
D. //

19. What does the input() function return?
A. int
B. str
C. float
D. bool

20. Which of the following is a Boolean value in Python?
A. Yes
B. No
C. True
D. Maybe

21. How do you start a for loop in Python?
A. for(i = 0; i < 5; i++)
B. for x in range(5):
C. foreach x in range(5):
D. loop x from 1 to 5

22. Which of the following is used for string formatting?
A. %
B. #
C. $
D. &

23. How do you create an empty dictionary in Python?
A. []
B. ()
C. {}
D. set()

24. Which of the following is not a keyword in Python?
A. elif
B. return
C. for
D. function

25. What is the output of type([])?
A. dict
B. list
C. set
D. tuple

26. Which function is used to convert a string to an integer?
A. str()
B. int()
C. float()
D. bool()

27. Which character is used to escape characters in Python?
A. /
B. \
C. |
D. *

28. What will print(“a” + “b”) output?
A. ab
B. a b
C. a+b
D. Error

29. Which of the following is used to handle exceptions in Python?
A. try-except
B. do-catch
C. handle-catch
D. error-check

30. Which keyword is used to stop a loop in Python?
A. stop
B. exit
C. break
D. return

31. What will print(3 > 5) return?
A. True
B. False
C. Error
D. None

32. What is the output of print(type(3.5))?
A. int
B. float
C. str
D. double

33. How is a block of code indicated in Python?
A. Semicolon
B. Braces
C. Indentation
D. Quotes

34. What is the index of the first element in a Python list?
A. 1
B. -1
C. 0
D. Depends on list

35. How do you declare a comment in Python?
A. // comment
B. # comment
C. /* comment */
D. — comment

36. What is the output of print(10 != 5)?
A. False
B. True
C. 0
D. Error

37. Which function is used to get the length of a string?
A. count()
B. len()
C. size()
D. length()

38. How do you round a number in Python?
A. round()
B. approx()
C. roundoff()
D. int()

39. What is the default value of an uninitialized variable in Python?
A. 0
B. “”
C. None
D. Undefined

40. Which one is the correct way to write a Python class?
A. class MyClass {}
B. MyClass: class
C. class MyClass:
D. def class MyClass()

41. Which loop runs at least once before checking condition?
A. for
B. while
C. do-while (not in Python)
D. if

42. Which method adds an item to a list?
A. insert()
B. add()
C. append()
D. push()

43. What is the keyword to define a class in Python?
A. function
B. class
C. object
D. def

44. What does is check in Python?
A. Type
B. Value
C. Identity
D. None

45. What does id() function return?
A. Memory location
B. Value
C. Type
D. Index

46. What is None in Python?
A. 0
B. Empty string
C. Special constant
D. False

47. What is the output of print(len(“Python”))?
A. 5
B. 6
C. 7
D. Error

48. Which of these are mutable?
A. tuple
B. list
C. str
D. int

49. What does range(5) return?
A. [1, 2, 3, 4, 5]
B. [0, 1, 2, 3, 4]
C. [0, 1, 2, 3, 4, 5]
D. [1, 2, 3, 4]

50. Which function is used to display output in Python?
A. echo
B. print
C. output
D. disp

Leave a Comment