Python Aptitude Test - MCQ Questions with Answers

This post presents a Python programming aptitude test with 25 multiple-choice questions for beginners.

These beginner-level MCQ questions cover essential aspects of Python programming and are designed to test fundamental understanding and basic syntax.

1. What does the len() function do in Python?

a) Counts the number of elements in a list
b) Returns the length of an object
c) Prints the length of an object
d) None of the above

2. Which data type is not allowed in Python?

a) int
b) char
c) float
d) str

3. What is the output of print(8 // 3)?

a) 2.67
b) 2
c) 3
d) 2.0

4. How do you create a list in Python?

a) []
b) ()
c) {}
d) ||

5. What keyword is used to define a function in Python?

a) function
b) def
c) func
d) define

6. Which of these is a boolean value in Python?

a) True
b) true
c) TRUE
d) T

7. How do you add an element to a list in Python?

a) list.add(element)
b) list.append(element)
c) list.put(element)
d) list.push(element)

8. What is the output of print("Python"[1])?

a) P
b) y
c) t
d) h

9. Which of the following loops is not a valid Python loop construct?

a) for
b) while
c) do-while
d) All of the above are valid

10. What does the break statement do?

a) Pauses the execution of the loop
b) Stops the execution of the loop and exits it
c) Breaks the program
d) Outputs an error

11. Which function converts a string to an integer in Python?

a) int()
b) str()
c) float()
d) bool()

12. How do you access the first element of a tuple named tuple1?

a) tuple1[0]
b) tuple1(0)
c) tuple1[1]
d) tuple1.first()

13. Which error occurs when you try to access an index that is out of bounds for a list?

a) IndexError
b) KeyError
c) ValueError
d) OutOfBoundsError

14. What is the correct way to check if an item is in a list in Python?

a) if item in list:
b) if contains(item, list):
c) if list.contains(item):
d) if item.exists(in list):

15. What is the correct file extension for Python files?

a) .pyt
b) .pt
c) .py
d) .python

16. How do you create a dictionary in Python?

a) {key: value}
b) [key: value]
c) (key: value)
d) <key: value>

17. What does the import statement do?

a) Adds a feature to Python
b) Deletes a module
c) Brings a module into the current namespace
d) Exports a module

18. Which method removes and returns the last item of a list?

a) list.delete()
b) list.remove()
c) list.pop()
d) list.push()

19. What is slicing in Python?

a) Cutting a program into smaller parts
b) A way to select a range of items from sequences like lists or strings
c) A method to iterate over sequences
d) A syntax error

20. What type of language is Python?

a) Compiled
b) Interpreted
c) Assembled
d) None of the above

21. Which method converts an integer to a string in Python?

a) str()
b) int()
c) string()
d) convert()

22. What does input() do in Python?

a) Displays output
b) Reads a line from user input
c) Exits the program
d) None of the above

23. What keyword is used to handle exceptions in Python?

a) handle
b) except
c) catch
d) error

24. What is the output of print(1 == "1")?

a) True
b) False
c) Error
d) 1

25. How do you check the type of a variable in Python?

a) type(var)
b) var.type()
c) typeof(var)
d) check(var)

Comments