🚀 Supercharge your YouTube channel's growth with AI.
Try YTGrowAI FreeTop 100 Python Basics MCQs with Answers for Beginners (2026)

With the help of AI tools, it has become easier than ever to build projects, even without understanding the fundamentals of the language.
This is where problems start. In interviews and exams, practical skills alone are not enough. What really matters is your understanding of logic, concepts, and the “why” behind the code. That’s the reason many people face rejection: “You can build, but you struggle to explain”.
That’s exactly why we created this set of 100 Python Basics MCQs. These questions are designed to test your conceptual understanding, covering almost all core topics. Many of them are previous interview questions and exam papers from top colleges and universities.
If you’re serious about improving your Python fundamentals, this is the perfect place to start.
100 Python Basics MCQs for Interviews and Exams
These 100 Python Basics MCQs are designed to help you check if your basics are strong enough to qualify for interviews and examinations. If you are able to answer most of these questions, you are on the right track. If not, focus on understanding the concepts behind each question. Just memorising answers won’t help in the long run.
Q1. Which of the following is the correct extension for a Python source file?
A. .python
B. .pi
C. .py
D. .p
Show Answer
Answer: C
Python source files are saved with the .py extension.
Q2. What is the output of print(2 ** 3) in Python?
A. 6
B. 8
C. 9
D. 5
Show Answer
Answer: B
The ** operator in Python is used for exponentiation (2 to the power of 3 is 8).
Q3. Which keyword is used to define a function in Python?
A. func
B. define
C. def
D. function
Show Answer
Answer: C
The def keyword is used to create or define a user-defined function.
Q4. What will be the data type of print(type(5.0))?
A. int
B. float
C. double
D. decimal
Show Answer
Answer: B
Any number with a decimal point is considered a float in Python.
Q5. Which symbol is used for single-line comments in Python?
A. //
B. /*
C. #
D. —
Show Answer
Answer: C
The hash (#) symbol is used to comment a single line in Python scripts.
Q6. What is the result of 10 // 3 in Python?
A. 3.33
B. 3
C. 4
D. 3.0
Show Answer
Answer: B
The // operator performs floor division, returning the largest integer less than or equal to the result.
Q7. Which of the following is a valid variable name in Python?
A. 1_variable
B. _variable1
C. var-iable
D. my var
Show Answer
Answer: B
Variable names can start with an underscore but cannot start with a number or contain hyphens/spaces.
Q8. How do you create a list in Python?
A. using curly braces {}
B. using parentheses ()
C. using square brackets []
D. using angle brackets <>
Show Answer
Answer: C
Lists in Python are created by placing elements inside square brackets.
Q9. What is the output of len(“Hello World”)?
A. 10
B. 11
C. 12
D. Error
Show Answer
Answer: B
The len() function counts all characters including spaces, resulting in 11.
Q10. Which data type is immutable in Python?
A. List
B. Dictionary
C. Tuple
D. Set
Show Answer
Answer: C
Tuples are immutable, meaning their elements cannot be changed after creation.
Q11. What is the correct syntax to output “Hello” in Python?
A. echo “Hello”
B. print(“Hello”)
C. Console.log(“Hello”)
D. printf(“Hello”)
Show Answer
Answer: B
Python uses the print() function to display output to the console.
Q12. What is the output of bool(0)?
A. True
B. False
C. 0
D. None
Show Answer
Answer: B
In Python, 0 is evaluated as False in a boolean context.
Q13. Which method is used to add an element to the end of a list?
A. add()
B. insert()
C. append()
D. extend()
Show Answer
Answer: C
The append() method adds a single item to the end of the list.
Q14. How do you start a try-except block in Python?
A. try: except:
B. catch: throw:
C. do: while:
D. attempt: error:
Show Answer
Answer: A
Python uses try and except keywords for exception handling.
Q15. What keyword is used to import a module in Python?
A. include
B. require
C. import
D. using
Show Answer
Answer: C
The import statement is used to include external modules into the script.
Q16. What is the output of 3 * ‘Py’?
A. 3Py
B. Py3
C. PyPyPy
D. Error
Show Answer
Answer: C
The * operator repeats the string the specified number of times.
Q17. Which statement is used to exit a loop prematurely?
A. exit
B. break
C. continue
D. stop
Show Answer
Answer: B
The break statement terminates the loop immediately and transfers execution to the statement following the loop.
Q18. What is the index of the first element in a Python list?
A. 1
B. 0
C. -1
D. start
Show Answer
Answer: B
Python uses zero-based indexing, so the first element is at index 0.
Q19. What is the output of print(type([]))?
A.
B.
C.
D.
Show Answer
Answer: B
Empty square brackets denote an empty list object.
Q20. Which operator is used for integer division?
A. /
B. %
C. //
D. **
Show Answer
Answer: C
The // operator performs floor division and returns an integer result.
Q21. How is a dictionary defined in Python?
A. Using []
B. Using ()
C. Using {}
D. Using “”
Show Answer
Answer: C
Dictionaries are defined using curly braces with key-value pairs.
Q22. What is the output of print(‘Py’ + ‘thon’)?
A. Py thon
B. Python
C. Py + thon
D. Error
Show Answer
Answer: B
The + operator concatenates two strings together.
Q23. Which method is used to remove the last element from a list?
A. remove()
B. delete()
C. pop()
D. clear()
Show Answer
Answer: C
The pop() method removes and returns the last item if no index is specified.
Q24. What is the data type of print(type({}))?
A. list
B. dict
C. set
D. tuple
Show Answer
Answer: B
Empty curly braces create an empty dictionary, not a set.
Q25. What is the value of x: x = 5 if 5 > 10 else 10?
A. 5
B. 10
C. 15
D. Error
Show Answer
Answer: B
This is a ternary operator; since 5 is not greater than 10, the else value (10) is assigned.
Q26. Which loop is used to iterate over a sequence (list, tuple, string)?
A. while loop
B. for loop
C. do-while loop
D. until loop
Show Answer
Answer: B
The for loop in Python is specifically designed to iterate over items in a sequence.
Q27. What is the output of print(10 % 3)?
A. 3
B. 1
C. 0
D. 3.33
Show Answer
Answer: B
The % operator returns the remainder of the division (10 divided by 3 is 3 remainder 1).
Q28. Which keyword is used to skip the current iteration in a loop?
A. break
B. pass
C. continue
D. skip
Show Answer
Answer: C
The continue statement skips the rest of the code inside the loop for the current iteration.
Q29. What does the input() function return by default?
A. Integer
B. Float
C. String
D. Boolean
Show Answer
Answer: C
The input() function always reads user input as a string.
Q30. How do you check if a key exists in a dictionary named ‘d’?
A. if key in d:
B. if d.has(key):
C. if d.exists(key):
D. check d[key]:
Show Answer
Answer: A
The ‘in’ keyword is used to check for membership in dictionary keys.
Q31. What is the output of bool(“False”)?
A. True
B. False
C. Error
D. None
Show Answer
Answer: A
Any non-empty string, including “False”, evaluates to True in boolean context.
Q32. Which symbol is used for exponentiation in Python?
A. ^
B. @
C. **
D. //
Show Answer
Answer: C
The double asterisk ** is the power operator in Python.
Q33. What is the output of print(type(1 + 2j))?
A. int
B. float
C. complex
D. imaginary
Show Answer
Answer: C
Numbers with a ‘j’ suffix denote complex numbers in Python.
Q34. Which method converts a string to lowercase in Python?
A. lower()
B. tolower()
C. lowercase()
D. isLower()
Show Answer
Answer: A
The lower() method returns a copy of the string converted to lowercase.
Q35. What is the correct file mode to open a file for reading and writing?
A. ‘r’
B. ‘w’
C. ‘r+’
D. ‘rw’
Show Answer
Answer: C
The ‘r+’ mode opens the file for both reading and writing without truncating it.
Q36. What is the output of print(10 == “10”)?
A. True
B. False
C. 10
D. Error
Show Answer
Answer: B
Comparison between an integer and a string returns False as they are different types.
Q37. Which function returns the largest item in an iterable?
A. max()
B. largest()
C. top()
D. high()
Show Answer
Answer: A
The max() function returns the item with the highest value.
Q38. What is the output of my_list = [1, 2, 3]; print(my_list[-1])?
A. 1
B. 2
C. 3
D. Error
Show Answer
Answer: C
Negative indexing accesses elements from the end of the list; -1 is the last item.
Q39. How do you define a tuple with a single item?
A. (1)
B. (1,)
C. [1]
D. {1}
Show Answer
Answer: B
A trailing comma is required for a single-item tuple to distinguish it from parentheses in expressions.
Q40. What is the purpose of the pass statement?
A. To exit a function
B. To skip a loop iteration
C. To act as a placeholder for future code
D. To raise an exception
Show Answer
Answer: C
The pass statement is a null operation; it does nothing and is used as a placeholder.
Q41. Which logical operator returns True if both operands are True?
A. or
B. and
C. not
D. xor
Show Answer
Answer: B
The and operator returns True only if both conditions are True.
Q42. What is the output of print(range(5))?
A. 0, 1, 2, 3, 4
B. 1, 2, 3, 4, 5
C. range(0, 5)
D. [0, 1, 2, 3, 4]
Show Answer
Answer: C
Printing a range object displays its representation, not the list of numbers.
Q43. Which method removes all elements from a list?
A. remove()
B. pop()
C. clear()
D. delete()
Show Answer
Answer: C
The clear() method removes all items from the list, leaving it empty.
Q44. What is the output of print(5 != 5)?
A. True
B. False
C. 1
D. Error
Show Answer
Answer: B
The != operator checks for inequality; since 5 is equal to 5, the result is False.
Q45. How do you access the value of a dictionary key?
A. dict[key]
B. dict(key)
C. dict.key
D. dict[value]
Show Answer
Answer: A
Dictionary values are accessed using square brackets with the key name.
Q46. What is a lambda function in Python?
A. A large function
B. An anonymous function
C. A recursive function
D. A function with a name
Show Answer
Answer: B
A lambda function is a small anonymous function defined with the lambda keyword.
Q47. Which function returns the ASCII value of a character?
A. ascii()
B. ord()
C. char()
D. hex()
Show Answer
Answer: B
The ord() function returns an integer representing the Unicode code point of the character.
Q48. What is slicing in Python?
A. Cutting a file
B. Extracting a portion of a sequence
C. Deleting items
D. Adding items
Show Answer
Answer: B
Slicing allows you to extract a part of a list, tuple, or string using a colon syntax.
Q49. Which keyword is used to raise an exception manually?
A. try
B. except
C. raise
D. throw
Show Answer
Answer: C
The raise keyword is used to trigger an exception explicitly.
Q50. What is the output of print(type(None))?
A.
B.
C.
D.
Show Answer
Answer: B
None is a special constant in Python with the data type NoneType.
Q51. Which method adds multiple elements to a set?
A. add()
B. update()
C. extend()
D. append()
Show Answer
Answer: B
The update() method accepts an iterable and adds all its elements to the set.
Q52. What is the result of 10 & 4 (Bitwise AND)?
A. 14
B. 0
C. 11
D. 1
Show Answer
Answer: B
In binary, 10 is 1010 and 4 is 0100; AND operation results in 0000 (0).
Q53. What does the is operator check?
A. Value equality
B. Object identity
C. Data type
D. Logical condition
Show Answer
Answer: B
The is operator checks if two variables point to the same object in memory.
Q54. What is the output of print(5 // 2 * 3)?
A. 6
B. 7.5
C. 7
D. 6.0
Show Answer
Answer: A
First 5//2 is calculated as 2 (integer division), then 2 * 3 is 6.
Q55. Which block is executed regardless of an exception in try-except?
A. else
B. finally
C. end
D. default
Show Answer
Answer: B
The finally block always executes, whether an exception occurred or not.
Q56. What is a Python module?
A. A folder
B. A file containing Python code
C. A built-in function
D. A class definition
Show Answer
Answer: B
A module is a file containing Python definitions and statements intended for use in other scripts.
Q57. What is the output of print(“hello”.capitalize())?
A. HELLO
B. Hello
C. hello
D. hEllo
Show Answer
Answer: B
The capitalize() method returns a string with the first character capitalized and the rest lowercased.
Q58. What is the main difference between list and tuple?
A. Lists are immutable, tuples are mutable
B. Lists use {}, tuples use []
C. Lists are mutable, tuples are immutable
D. Lists store numbers, tuples store strings
Show Answer
Answer: C
Lists can be modified after creation (mutable), whereas tuples cannot (immutable).
Q59. Which function is used to get the length of a list?
A. length()
B. len()
C. size()
D. count()
Show Answer
Answer: B
len() is a built-in function used to return the number of items in a container.
Q60. How do you start a comment block in Python?
A. /*
B. //
C. “””
D. ##
Show Answer
Answer: C
Triple quotes (”’ or “””) are used for multi-line strings or docstrings, often used as block comments.
Q61. What does the .keys() method return for a dictionary?
A. A list of values
B. A list of keys
C. A view object of keys
D. A tuple of keys
Show Answer
Answer: C
The keys() method returns a view object that displays a list of all the keys.
Q62. What is the output of print(2 * 3 ** 2)?
A. 36
B. 18
C. 12
D. 64
Show Answer
Answer: B
Exponentiation has higher precedence than multiplication, so 3**2 (9) is calculated first, then 2*9.
Q63. Which method removes a specific element by value from a list?
A. pop()
B. del
C. remove()
D. clear()
Show Answer
Answer: C
The remove() method searches for the first occurrence of the value and removes it.
Q64. What is Python’s floor division operator?
A. /
B. %
C. //
D. |
Show Answer
Answer: C
The // operator divides and rounds down to the nearest integer.
Q65. What is the output of str(123)?
A. 123
B. “123”
C. 123.0
D. Error
Show Answer
Answer: B
The str() function converts the integer 123 into the string “123”.
Q66. Which keyword is used for defining a class in Python?
A. struct
B. class
C. def
D. object
Show Answer
Answer: B
The class keyword is used to create a blueprint for objects.
Q67. What is the self parameter in Python methods?
A. It refers to the parent class
B. It refers to the current instance of the class
C. It is a global variable
D. It is a keyword to define static methods
Show Answer
Answer: B
self represents the instance of the class and is used to access class attributes.
Q68. What is the output of list(range(3))?
A. [1, 2, 3]
B. [0, 1, 2]
C. (0, 1, 2)
D. range(0, 3)
Show Answer
Answer: B
range(3) generates numbers from 0 to 2, which list() converts to [0, 1, 2].
Q69. How do you define a set?
A. Using []
B. Using ()
C. Using {}
D. Using set{}
Show Answer
Answer: C
Sets are defined using curly braces with unique elements.
Q70. What type of data does a set hold?
A. Unique elements only
B. Mutable elements only
C. Duplicate elements
D. Key-value pairs
Show Answer
Answer: A
Sets automatically remove duplicate values and store only unique elements.
Q71. What is the output of print(type(type(int)))?
A.
B.
C.
D. Error
Show Answer
Answer: A
The type of any class (like int, str) or the type function itself is ‘type’.
Q72. Which statement correctly copies a list ‘a’ to ‘b’?
A. b = a
B. b = a.copy()
C. b = a[:]
D. Both B and C
Show Answer
Answer: D
Using .copy() or slicing [:] creates a shallow copy; ‘b = a’ creates a reference.
Q73. What is the default return value of a function without a return statement?
A. 0
B. Empty string
C. None
D. False
Show Answer
Answer: C
If a function doesn’t explicitly return a value, it returns None.
Q74. What is the output of print(3 in [1, 2, 3])?
A. 3
B. True
C. False
D. Yes
Show Answer
Answer: B
The in operator checks for membership and returns True if the item is found.
Q75. Which function converts an integer to a string?
A. integer()
B. str()
C. string()
D. char()
Show Answer
Answer: B
The str() function converts various data types into a string representation.
Q76. What does the find() method return if a substring is not found?
A. 0
B. -1
C. None
D. Error
Show Answer
Answer: B
The find() method returns -1 if the substring does not exist in the string.
Q77. What is the syntax for a single-line if statement?
A. if x > 0: print(“Positive”)
B. if (x > 0) { print(“Positive”); }
C. if x > 0 then print(“Positive”)
D. if x > 0 print(“Positive”)
Show Answer
Answer: A
Python uses indentation and a colon for block definition, allowing a single line statement.
Q78. How do you define a global variable inside a function?
A. var x = 10
B. global x
C. public x
D. static x
Show Answer
Answer: B
The global keyword allows you to modify a variable outside the current scope.
Q79. What is the output of print(float(5))?
A. 5
B. 5.0
C. “5.0”
D. 05.00
Show Answer
Answer: B
The float() function converts an integer to a floating-point number.
Q80. Which method sorts a list in place?
A. sorted()
B. sort()
C. order()
D. arrange()
Show Answer
Answer: B
sort() modifies the original list directly, while sorted() returns a new list.
Q81. What is the output of print(“hello”.replace(“l”, “p”))?
A. heppo
B. heppp
C. helpp
D. hello
Show Answer
Answer: A
The replace() method replaces all occurrences of the old substring with the new one.
Q82. Which method is used to split a string into a list?
A. split()
B. cut()
C. break()
D. slice()
Show Answer
Answer: A
split() splits the string by a specified separator (default is whitespace).
Q83. What is the output of print(0 and 5)?
A. 5
B. 0
C. True
D. False
Show Answer
Answer: B
The and operator returns the first falsy value; 0 is falsy.
Q84. What does del my_list[2] do?
A. Deletes the list
B. Deletes the element at index 2
C. Deletes the first two elements
D. Clears the list
Show Answer
Answer: B
The del statement removes the item at the specified index.
Q85. Which function returns a string containing a printable representation of an object?
A. str()
B. repr()
C. print()
D. format()
Show Answer
Answer: B
repr() returns a string that would yield an object with the same value when passed to eval().
Q86. How do you define a default argument in a function?
A. def func(x = 1):
B. def func(default x = 1):
C. def func(x default 1):
D. def func(1 = x):
Show Answer
Answer: A
Default arguments are defined using the equals sign in the function header.
Q87. What is the output of print(0 or 5)?
A. 0
B. 5
C. True
D. False
Show Answer
Answer: B
The or operator returns the first truthy value; 0 is falsy, so it returns 5.
Q88. Which exception is raised when dividing by zero?
A. ValueError
B. TypeError
C. ZeroDivisionError
D. ArithmeticError
Show Answer
Answer: C
Python raises ZeroDivisionError when the second operator in division is zero.
Q89. What is the output of print(2 ** 3 ** 2)?
A. 64
B. 512
C. 36
D. 12
Show Answer
Answer: B
Exponentiation is right-associative, so it is evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512.
Q90. What does the id() function return?
A. Variable name
B. Identity (memory address) of an object
C. Data type
D. Value of the object
Show Answer
Answer: B
id() returns the unique identifier for the specified object, which is its memory address.
Q91. What is the output of print(type(()))?
A.
B.
C.
D.
Show Answer
Answer: C
Empty parentheses are used to define an empty tuple.
Q92. Which method is used to join elements of a list into a string?
A. join()
B. merge()
C. concat()
D. attach()
Show Answer
Answer: A
The join() method is a string method that joins list elements using the string as a separator.
Q93. What is a local variable?
A. A variable declared outside a function
B. A variable declared inside a function
C. A variable that never changes
D. A variable used in all functions
Show Answer
Answer: B
Local variables are defined inside a function and can only be accessed within that function.
Q94. What is the output of print(int(‘101’, 2))?
A. 101
B. 5
C. 2
D. Error
Show Answer
Answer: B
int() with a base argument converts a string in that base (binary here) to a decimal integer.
Q95. Which keyword is used to check variable type in a conditional?
A. type
B. isinstance()
C. typeof
D. check
Show Answer
Answer: B
isinstance() is the preferred way to check if an object is an instance of a class.
Q96. What is the output of print(“Hello”[1:4])?
A. Hell
B. ell
C. Hel
D. ello
Show Answer
Answer: B
Slicing [1:4] starts at index 1 (‘e’) and stops before index 4 (‘o’), resulting in ‘ell’.
Q97. What is the purpose of the __init__ method?
A. To delete an object
B. To initialize the object attributes
C. To import a module
D. To print the object
Show Answer
Answer: B
__init__ is the constructor method used to initialize the object’s state when it is created.
Q98. What is the output of print(5 != 5 or 5 > 3)?
A. False
B. True
C. Error
D. 5
Show Answer
Answer: B
The first condition is False, but the second (5 > 3) is True, so the ‘or’ result is True.
Q99. Which function opens a file?
A. open()
B. fopen()
C. file()
D. load()
Show Answer
Answer: A
The open() function is used to open a file and returns a file object.
Q100. What is the output of print(max([1, 5, 3, 2]))?
A. 1
B. 2
C. 3
D. 5
Show Answer
Answer: D
The max() function returns the largest item in the provided iterable.
Conclusion
When you first try Python, it feels amazing. It’s simple, fast, and easy to understand. In just a few weeks, you’re already building small projects. That early progress feels exciting. You start believing you’re ready for interviews and exams.
But when you actually face them, the questions are different. You’re asked why you used a certain approach, why a specific library, and why your logic works the way it does. In 2026, anyone can write code with the help of AI, but understanding the logic behind it is what truly sets you apart.
If you understand the logic, you can always use AI to speed up your coding. But if you rely on AI for thinking, it becomes difficult to explain your decisions, and that’s where most candidates get rejected.
That’s where these 100 Python Basics MCQs help you. Instead of passively reading theory, you actively test your understanding. Go through these questions multiple times, focus on the concepts behind each answer, and you’ll build the confidence needed to clear interviews and exams.
If you want to go further, continue your preparation with these popular MCQ sets:
For popular Python libraries MCQs :
For data structures:
To test your database skills:
For advanced OOP concepts:
Thank you for preparing with us!


