Loading Python...
0 / 0 completed

Mock Test 3

Practice Test — Same Syllabus, Different Questions

Answer all questions. Your progress is saved automatically.

Q1 (A)

Fill in the Blanks

1. Every if and elif line must end with a __________.

2. The __________ statement provides an alternative when the if condition is false.

3. range(0, 10, 3) produces 0, 3, 6, and __________.

4. min(100, 50, 75) returns __________.

5. The __________ method replaces part of a string with new text.

6. len("Hello World") returns __________.

7. The and operator returns True only when __________ conditions are True.

8. In binary, 8 is written as __________.

9. sum([]) returns __________.

10. The __________ keyword is used to check multiple conditions after an if.

Q1 (B)

State True or False

1. A for loop can count backwards using a negative step.

2. "Hello".upper() changes the original string.

3. or returns True when both conditions are False.

4. input() converts user input to integer automatically.

Q2

Read the Code and Write the Output

Q2.1
x = 15
if x % 3 == 0:
    print("Fizz")
elif x % 5 == 0:
    print("Buzz")
else:
    print(x)

Output:

Q2.2
for i in range(2, 11, 2):
    print(i, end=" ")

What does this print?

Q2.3
data = [4, 8, 2, 6]
print(sum(data) - min(data))

Output:

Q2.4
s = "PyThOn"
print(s.lower().replace("python", "java"))

Output:

Q2.5

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

for i in range(1, 6):
    print("*" * i)

    
  
Q2.6
x = 0
y = 5
if x and y:
    print("Both")
elif x or y:
    print("One")
else:
    print("None")

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 Grade Program

This program should print the grade based on marks. Find and fix the error:


    
  
Q3.2 — Fix the Loop

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


    
  
Q3.3 — Fix the Input Program

This should ask for a name and greet the user. Find and fix the error:


    
  
Q3.4 — Fix the Length Check

This should print the length of a list. Find and fix the error:


    
  
Q3.5 — Fix the Comparison

This should print "yes" if 5 is between 3 and 10. Find and fix the error:


    
  
Q3.6 — Fix the Sum Loop

This should calculate the sum of 1 to 5. Find and fix the error:


    
  
Q4 (A)

Perform Binary Addition

Q4a

Solve: 1110 + 0011

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

Q4b

Solve: 1001 + 1001

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

Q4c

Solve: 10011 + 01100

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

Q4d

Solve: 11101 + 00111

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 character is a vowel or consonant. Test with char = "e".


    
  
Q6.2

Write a program to print the reverse of a string using a for loop. Test with text = "Python".


    
  
Q6.3

Write a program to find whether a number is a multiple of both 3 and 7. Test with num = 21.


    
  
Q6.4

Write a program to convert temperature from Celsius to Fahrenheit (F = C * 9/5 + 32). Test with celsius = 37.


    
  
Q6.5

Write a program to print all numbers from 1 to 50 that are divisible by 7.


    
  
Q6.6

Write a program using len(), max(), min() on a string to show the character count, largest character, and smallest character. Test with word = "python".


    
  
Q6.7

Write a program to check if a student passes: marks >= 40 in both subjects. Test with math = 55, science = 35.


    
  
Q6.8

Write a program to print a diamond pattern with 5 rows of stars.


    
  

Ready to check your score?

Answer at least 75% of the questions to unlock scoring.