Mock Test 1
Practice Test — Same Syllabus, Different Questions
Answer all questions. Your progress is saved automatically.
Fill in the Blanks
1. The if keyword is used for __________ making in Python.
2. The __________ block runs when all conditions above it are false.
3. A for loop variable takes each value from a __________.
4. range(5) generates numbers from 0 to __________.
5. The ________() function counts the number of characters in a string.
6. To get the smallest number from a list, use the ________() function.
7. The sum() function works on a __________, not individual numbers.
8. input() always returns a __________.
9. The .upper() method converts a string to __________.
10. In binary, 1 + 1 equals __________.
State True or False
1. elif can be used without an if before it.
2. range(1, 5) includes the number 5.
3. max() can find the largest value in a list.
4. The .replace() method changes the original string.
Read the Code and Write the Output
x = 10
if x > 5:
print("Big")
else:
print("Small")Output:
for i in range(3):
print(i * 2)What is the last line of output?
numbers = [3, 7, 1, 9]
print(max(numbers))Output:
text = "hello"
print(text.upper())Output:
What does this code print? Type it in and run to verify:
for i in range(1, 6):
if i % 2 != 0:
print(i)x = 5
y = 3
if x > y and x > 0:
print("Yes")
else:
print("No")Output:
Read the Code and Find the Errors
Each snippet has an error. Fix the code so it runs correctly.
This should print "five" when x equals 5. Find and fix the error:
This should print numbers 0 through 9. Find and fix the error:
This should print the name in uppercase. Find and fix the error:
This should print the sum of the first two numbers. Find and fix the error:
This should print "ten" when x equals 10. Find and fix the error:
This should print numbers 0 through 4. Find and fix the error:
Perform Binary Addition
Solve: 1010 + 0101
Enter the result (5 bits, left to right):
Solve: 1101 + 0110
Enter the result (5 bits, left to right):
Solve: 10010 + 01101
Enter the result (6 bits, left to right):
Solve: 11011 + 00110
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 3. Test with num = 9.
Write a program to print all odd numbers from 1 to 15.
Write a program to find the largest of three numbers using if-elif-else. Test with a = 10, b = 25, c = 18.
Write a program to convert a string to lowercase and replace "hello" with "hi". Test with text = "Hello World Hello".
Write a program to print numbers 10 to 1 (countdown) using range with a negative step.
Write a program to calculate the sum of even numbers from 1 to 20.
Write a program to check if a number is between 10 and 50 using and. Test with num = 30.
Write a program to print a star pattern — inverted triangle (5 rows: *****, ****, ***, **, *).
Ready to check your score?
Answer at least 75% of the questions to unlock scoring.