Python Practice Exam
Section 1: Multiple Choice Questions (10)
1. What is the correct data type of 3.14 in Python? a) int b) float c) str d) bool
2. Which of the following is a valid variable name in Python? a) 1number b) number_1 c)
number-1 d) number one
3. What is the output of: print(7 // 2)? a) 3 b) 3.5 c) 4 d) Error
4. Which operator is used to calculate remainder in Python? a) // b) % c) / d) **
5. What will be the output? x = 5 if x > 3: print('Yes') else: print('No') a) Yes b) No c) Error
d) Nothing
6. Which function is used to find the length of a list? a) count() b) length() c) len() d) size()
7. What is the output? my_list = [10, 20, 30] print(my_list[1]) a) 10 b) 20 c) 30 d) Error
8. Which of the following is NOT a Python data type? a) int b) float c) real d) str
9. What will be the result of: print(2 ** 3)? a) 5 b) 6 c) 8 d) 9
10. Which keyword is used for conditions in Python? a) while b) if c) switch d) elif
Section 2: True or False (5)
11. In Python, variables must be declared with their data type. ( )
12. The operator '//' gives the integer division result. ( )
13. Lists in Python are mutable (can be changed). ( )
14. The keyword 'else if' is used in Python. ( )
15. The expression '"5" + 5' will output 10. ( )
Section 3: Coding Questions (5)
16. Write a Python code that takes a number from the user and prints whether it is positive
or negative.
17. Create a list of 5 numbers, then print the first and last elements.
18. Write Python code to calculate the sum of two variables a = 7, b = 3 and print the
result.
19. Write a program that checks if a number is even or odd using if.
20. Write Python code to store your name and age in variables, then print them in the
format: My name is [Name] and I am [Age] years old.