Explore 100 Python Basics MCQs with answers designed for beginners. Perfect for exams, interviews, quizzes, and learning Python fundamentals step by step. Python is one of the most popular and beginner-friendly programming languages used today for web development, data science, automation, and software development. This carefully prepared set of 100 Python Basics MCQs with answers is designed to help beginners, students, and aspiring programmers build a strong foundation in Python programming. These multiple choice questions cover essential topics such as variables, data types, operators, loops, functions, lists, tuples, dictionaries, and basic syntax. Whether you are preparing for exams, job interviews, online quizzes, or self-assessment, these Python MCQs will help you test your knowledge, improve your understanding, and gain confidence in Python fundamentals.
Python Basics – 100 MCQs with Answers
1. What is Python?
A. A markup language
B. A high-level programming language
C. A database
D. An operating system
Answer: B
2. Who developed Python?
A. Dennis Ritchie
B. James Gosling
C. Guido van Rossum
D. Bjarne Stroustrup
Answer: C
3. Which year was Python first released?
A. 1989
B. 1991
C. 2000
D. 2010
Answer: B
4. Python is known for:
A. Complex syntax
B. Low readability
C. Simple and readable syntax
D. Hardware control
Answer: C
5. Which symbol is used to write comments in Python?
A. //
B. /* */
C. #
D. <!– –>
Answer: C
6. Which of the following is the correct file extension for Python files?
A. .pt
B. .py
C. .python
D. .pyt
Answer: B
7. Which keyword is used to display output in Python?
A. echo
B. print
C. display
D. output
Answer: B
8. What will print("Hello World") display?
A. Hello
B. World
C. Hello World
D. Error
Answer: C
9. Python is:
A. Compiled only
B. Interpreted only
C. Both compiled and interpreted
D. Machine language
Answer: B
10. Which of the following is a valid Python variable name?
A. 2value
B. value-2
C. value_2
D. value 2
Answer: C
11. Which data type is used to store whole numbers?
A. float
B. str
C. int
D. bool
Answer: C
12. Which data type stores decimal numbers?
A. int
B. float
C. complex
D. str
Answer: B
13. Which data type is used to store text?
A. int
B. float
C. str
D. char
Answer: C
14. What is the output of type(10)?
A. <class 'float'>
B. <class 'str'>
C. <class 'int'>
D. <class 'number'>
Answer: C
15. Which value represents True in Python?
A. 0
B. 1
C. “True”
D. None
Answer: B
16. Which keyword is used to define a function?
A. func
B. define
C. def
D. function
Answer: C
17. What is the correct way to create a function?
A. function myFunc():
B. def myFunc():
C. create myFunc():
D. func myFunc():
Answer: B
18. Which statement is used to end a function and return a value?
A. break
B. stop
C. return
D. end
Answer: C
19. Which keyword is used for decision making?
A. for
B. if
C. while
D. break
Answer: B
20. Which operator is used for equality comparison?
A. =
B. ==
C. !=
D. >=
Answer: B
21. What does = mean in Python?
A. Comparison
B. Assignment
C. Equality
D. Logical operator
Answer: B
22. Which loop is used when the number of iterations is known?
A. while
B. do-while
C. for
D. repeat
Answer: C
23. Which loop continues while a condition is true?
A. for
B. while
C. if
D. switch
Answer: B
24. Which keyword stops a loop immediately?
A. stop
B. exit
C. break
D. end
Answer: C
25. Which keyword skips the current iteration?
A. skip
B. pass
C. continue
D. break
Answer: C
26. What is a list in Python?
A. Immutable collection
B. Mutable collection
C. Fixed-size array
D. Function
Answer: B
27. Which symbol is used to create a list?
A. {}
B. ()
C. []
D. <>
Answer: C
28. Which data structure is immutable?
A. List
B. Dictionary
C. Tuple
D. Set
Answer: C
29. Which symbol is used for tuples?
A. []
B. {}
C. ()
D. ||
Answer: C
30. Which data structure stores key-value pairs?
A. List
B. Tuple
C. Set
D. Dictionary
Answer: D
31. Which symbol is used to define a dictionary?
A. []
B. ()
C. {}
D. <>
Answer: C
32. What does len() do?
A. Adds values
B. Finds data type
C. Counts items
D. Deletes items
Answer: C
33. Which function is used to take input from the user?
A. get()
B. read()
C. input()
D. scan()
Answer: C
34. What type does input() return?
A. int
B. float
C. str
D. bool
Answer: C
35. Which keyword is used to handle exceptions?
A. error
B. catch
C. try
D. handle
Answer: C
36. Which block runs if an exception occurs?
A. try
B. else
C. finally
D. except
Answer: D
37. Which block always executes?
A. try
B. except
C. finally
D. error
Answer: C
38. What does import do?
A. Exports code
B. Deletes module
C. Loads module
D. Compiles code
Answer: C
39. Which module is used for mathematical functions?
A. math
B. random
C. sys
D. os
Answer: A
40. Which module is used to generate random numbers?
A. math
B. random
C. time
D. sys
Answer: B
41. What does None represent?
A. Zero
B. Empty string
C. No value
D. False
Answer: C
42. Python supports:
A. Object-oriented programming
B. Functional programming
C. Procedural programming
D. All of the above
Answer: D
43. Which operator is used for exponentiation?
A. ^
B. **
C. %
D. //
Answer: B
44. What does // operator do?
A. Division
B. Floor division
C. Modulus
D. Power
Answer: B
45. Which operator gives remainder?
A. /
B. //
C. %
D. **
Answer: C
46. Which statement checks multiple conditions?
A. if
B. if-else
C. elif
D. switch
Answer: C
47. What is indentation in Python?
A. Code alignment
B. Error
C. Comment
D. Variable
Answer: A
48. Indentation in Python is used for:
A. Decoration
B. Code grouping
C. Performance
D. Styling only
Answer: B
49. Python is:
A. Case-sensitive
B. Case-insensitive
C. Semi case-sensitive
D. Not case-related
Answer: A
50. Which keyword creates a class?
A. struct
B. class
C. object
D. define
Answer: B
51. What is an object?
A. Function
B. Variable
C. Instance of a class
D. Module
Answer: C
52. Which keyword refers to the current object?
A. this
B. self
C. current
D. object
Answer: B
53. Which function converts string to integer?
A. str()
B. float()
C. int()
D. chr()
Answer: C
54. Which function converts integer to string?
A. int()
B. str()
C. chr()
D. bool()
Answer: B
55. What does bool(0) return?
A. True
B. False
C. None
D. Error
Answer: B
56. Which collection does not allow duplicate values?
A. List
B. Tuple
C. Dictionary
D. Set
Answer: D
57. Which method adds an element to a list?
A. add()
B. insert()
C. append()
D. push()
Answer: C
58. Which method removes an element from a list?
A. delete()
B. pop()
C. remove()
D. Both B and C
Answer: D
59. Which statement is used to exit a program?
A. stop
B. exit
C. quit
D. Both B and C
Answer: D
60. What is PEP 8?
A. Python error code
B. Style guide for Python
C. Python editor
D. Python library
Answer: B
61. Which function checks data type?
A. check()
B. typeof()
C. type()
D. datatype()
Answer: C
62. What does range(5) generate?
A. 1 to 5
B. 0 to 4
C. 0 to 5
D. 1 to 4
Answer: B
63. Which keyword is used to define constants?
A. const
B. final
C. static
D. None (Python has no constants keyword)
Answer: D
64. Which operator is logical AND?
A. &&
B. and
C. &
D. AND
Answer: B
65. Which operator is logical OR?
A. ||
B. or
C. |
D. OR
Answer: B
66. Which operator is logical NOT?
A. !
B. not
C. ~
D. !=
Answer: B
67. What does pass do?
A. Stops program
B. Skips iteration
C. Does nothing
D. Raises error
Answer: C
68. Which function rounds a number?
A. round()
B. floor()
C. ceil()
D. approx()
Answer: A
69. Which module works with dates and time?
A. time
B. date
C. datetime
D. Both A and C
Answer: D
70. Which keyword deletes a variable?
A. remove
B. del
C. delete
D. clear
Answer: B
71. Which collection is ordered?
A. Set
B. Dictionary (older versions unordered)
C. List
D. Set only
Answer: C
72. Which Python version introduced print as a function?
A. Python 1
B. Python 2
C. Python 3
D. Python 4
Answer: C
73. Which symbol is used for slicing?
A. ;
B. :
C. ,
D. .
Answer: B
74. What does is operator check?
A. Equality
B. Identity
C. Type
D. Value
Answer: B
75. Which function sorts a list?
A. sort()
B. order()
C. arrange()
D. sortedlist()
Answer: A
76. Which function returns a sorted copy of a list?
A. sort()
B. sorted()
C. order()
D. copy()
Answer: B
77. Which keyword creates an anonymous function?
A. func
B. lambda
C. anon
D. def
Answer: B
78. What does len("Python") return?
A. 5
B. 6
C. 7
D. Error
Answer: B
79. Which method converts string to lowercase?
A. lower()
B. down()
C. small()
D. toLower()
Answer: A
80. Which method converts string to uppercase?
A. up()
B. upper()
C. capital()
D. big()
Answer: B
81. What does strip() do?
A. Removes spaces
B. Adds spaces
C. Replaces text
D. Splits text
Answer: A
82. Which method splits a string?
A. cut()
B. break()
C. split()
D. divide()
Answer: C
83. Which method joins elements into a string?
A. join()
B. merge()
C. add()
D. combine()
Answer: A
84. Which symbol is used for membership testing?
A. in
B. has
C. includes
D. contain
Answer: A
85. Which keyword is used to create inheritance?
A. inherit
B. extends
C. super
D. class
Answer: D
86. Which function opens a file?
A. open()
B. file()
C. read()
D. write()
Answer: A
87. Which mode opens a file for reading?
A. w
B. a
C. r
D. rw
Answer: C
88. Which mode appends data to a file?
A. r
B. w
C. a
D. x
Answer: C
89. Which keyword is used to raise an exception?
A. throw
B. error
C. raise
D. exception
Answer: C
90. Which statement checks if a key exists in dictionary?
A. has
B. in
C. exists
D. keyin
Answer: B
91. Python code blocks are defined by:
A. Curly braces
B. Parentheses
C. Indentation
D. Semicolon
Answer: C
92. Which function converts a list to tuple?
A. list()
B. tuple()
C. set()
D. dict()
Answer: B
93. Which function converts tuple to list?
A. tuple()
B. set()
C. list()
D. dict()
Answer: C
94. Which keyword creates a generator?
A. generate
B. yield
C. return
D. produce
Answer: B
95. Which keyword is used for debugging?
A. debug
B. assert
C. test
D. check
Answer: B
96. Which symbol is used for indexing?
A. ()
B. {}
C. []
D. <>
Answer: C
97. Python lists are:
A. Immutable
B. Fixed size
C. Mutable
D. Static
Answer: C
98. Which function gives absolute value?
A. abs()
B. fabs()
C. mod()
D. absolute()
Answer: A
99. Which keyword checks a condition repeatedly?
A. for
B. while
C. if
D. loop
Answer: B
100. Python is mainly used for:
A. Web development
B. Data science
C. Automation
D. All of the above
Answer: D
Advertisement:


