Loading Python...
0 / 0 completed

Mock Test 1

Practice Test — Same Syllabus, Different Questions

Answer all questions. Your progress is saved automatically.

Q1 (A)

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 __________.

Q1 (B)

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.

Q2

Read the Code and Write the Output

Q2.1
x = 10
if x > 5:
    print("Big")
else:
    print("Small")

Output:

Q2.2
for i in range(3):
    print(i * 2)

What is the last line of output?

Q2.3
numbers = [3, 7, 1, 9]
print(max(numbers))

Output:

Q2.4
text = "hello"
print(text.upper())

Output:

Q2.5

What does this code print? Type it in and run to verify:

for i in range(1, 6):
    if i % 2 != 0:
        print(i)

    
  
Q2.6
x = 5
y = 3
if x > y and x > 0:
    print("Yes")
else:
    print("No")

Output:

Q3

Read the Code and Find the Errors

Each snippet has an error. Fix the code so it runs correctly.

Q3.1 — Fix the If Statement

This should print "five" when x equals 5. Find and fix the error:


    
  
Q3.2 — Fix the For Loop

This should print numbers 0 through 9. Find and fix the error:


    
  
Q3.3 — Fix the String Method

This should print the name in uppercase. Find and fix the error:


    
  
Q3.4 — Fix the Sum Call

This should print the sum of the first two numbers. Find and fix the error:


    
  
Q3.5 — Fix the Comparison

This should print "ten" when x equals 10. Find and fix the error:


    
  
Q3.6 — Fix the Loop Syntax

This should print numbers 0 through 4. Find and fix the error:


    
  
Q4 (A)

Perform Binary Addition

Q4a

Solve: 1010 + 0101

Enter the result (5 bits, left to right):

Q4b

Solve: 1101 + 0110

Enter the result (5 bits, left to right):

Q4c

Solve: 10010 + 01101

Enter the result (6 bits, left to right):

Q4d

Solve: 11011 + 00110

Enter the result (6 bits, left to right):

Q6

Write Python Programs

Write working code for each task. Click Run to test.

Q6.1

Write a program to check if a number is divisible by 3. Test with num = 9.


    
  
Q6.2

Write a program to print all odd numbers from 1 to 15.


    
  
Q6.3

Write a program to find the largest of three numbers using if-elif-else. Test with a = 10, b = 25, c = 18.


    
  
Q6.4

Write a program to convert a string to lowercase and replace "hello" with "hi". Test with text = "Hello World Hello".


    
  
Q6.5

Write a program to print numbers 10 to 1 (countdown) using range with a negative step.


    
  
Q6.6

Write a program to calculate the sum of even numbers from 1 to 20.


    
  
Q6.7

Write a program to check if a number is between 10 and 50 using and. Test with num = 30.


    
  
Q6.8

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.