Mock Test 2
Practice Test — Same Syllabus, Different Questions
Answer all questions. Your progress is saved automatically.
Fill in the Blanks
1. Python uses __________ to group code blocks inside if/else/for.
2. The elif keyword is short for __________.
3. range(2, 8) generates numbers from 2 to __________.
4. The __________ function returns the total of all numbers in a list.
5. len([10, 20, 30, 40]) returns __________.
6. The .lower() method converts text to __________.
7. max(3, 8, 5) returns __________.
8. A __________ loop repeats code a specific number of times.
9. In binary, the number 5 is written as __________.
10. The __________() function is used to get input from the user.
State True or False
1. Python checks elif conditions from bottom to top.
2. len() can count characters in a string.
3. 0 + 0 in binary equals 1.
4. sum() can add individual numbers like sum(1, 2, 3).
Read the Code and Write the Output
x = 3
if x >= 3:
print("yes")
else:
print("no")Output:
for i in range(5, 0, -1):
print(i)What is the first line of output?
words = "Python"
print(len(words))Output:
msg = "HELLO WORLD"
print(msg.lower())Output:
What does this code print? Type it in and run to verify:
total = 1
for i in range(1, 5):
total = total * i
print(total)a = True
b = False
print(a or b)Output:
Read the Code and Find the Errors
Each snippet has an error. Fix the code so it runs correctly.
This should print "big" if x is greater than 3. Find the error:
This should print even numbers from 1 to 9. Find the error:
This should replace "hello" with "hi". Find the error:
This should print the largest number in the list. Find the error:
This should print "Young adult" if age is between 18 and 30. Find the error:
This should print numbers 0 through 4. Find and fix the error:
Perform Binary Addition
Solve: 1100 + 0011
Enter the result (5 bits, left to right):
Solve: 1011 + 0101
Enter the result (5 bits, left to right):
Solve: 10101 + 01010
Enter the result (6 bits, left to right):
Solve: 11001 + 01110
Enter the result (6 bits, left to right):
Write Python Programs
Write working code for each task. Click Run to test.
Write a program to check if a number is divisible by both 5 and 11. Test with num = 55.
Write a program to print the first 10 multiples of 3 (3, 6, 9 ... 30).
Write a program to find the smallest of three numbers using if-elif-else. Test with a=12, b=5, c=20.
Write a program to count vowels in a string using a for loop. Test with text = "Hello World".
Write a program to print numbers 1 to 20 that are divisible by 3 or 5.
Write a program to calculate the average of the list [80, 90, 70, 85, 95] using sum() and len().
Write a program to check if a year is a leap year using and/or. Test with year = 1900.
Write a program to print a number pyramid pattern:
1
12
123
1234
12345Ready to check your score?
Answer at least 75% of the questions to unlock scoring.