Loading Python...
0 / 0 completed

Mock Test 2

Practice Test — Same Syllabus, Different Questions

Answer all questions. Your progress is saved automatically.

Q1 (A)

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.

Q1 (B)

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

Q2

Read the Code and Write the Output

Q2.1
x = 3
if x >= 3:
    print("yes")
else:
    print("no")

Output:

Q2.2
for i in range(5, 0, -1):
    print(i)

What is the first line of output?

Q2.3
words = "Python"
print(len(words))

Output:

Q2.4
msg = "HELLO WORLD"
print(msg.lower())

Output:

Q2.5

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)

    
  
Q2.6
a = True
b = False
print(a or b)

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 "big" if x is greater than 3. Find the error:


    
  
Q3.2 — Fix the Even Number Finder

This should print even numbers from 1 to 9. Find the error:


    
  
Q3.3 — Fix the String Replace

This should replace "hello" with "hi". Find the error:


    
  
Q3.4 — Fix the Max Function

This should print the largest number in the list. Find the error:


    
  
Q3.5 — Fix the Age Check

This should print "Young adult" if age is between 18 and 30. Find the error:


    
  
Q3.6 — Fix the Loop

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


    
  
Q4 (A)

Perform Binary Addition

Q4a

Solve: 1100 + 0011

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

Q4b

Solve: 1011 + 0101

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

Q4c

Solve: 10101 + 01010

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

Q4d

Solve: 11001 + 01110

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 both 5 and 11. Test with num = 55.


    
  
Q6.2

Write a program to print the first 10 multiples of 3 (3, 6, 9 ... 30).


    
  
Q6.3

Write a program to find the smallest of three numbers using if-elif-else. Test with a=12, b=5, c=20.


    
  
Q6.4

Write a program to count vowels in a string using a for loop. Test with text = "Hello World".


    
  
Q6.5

Write a program to print numbers 1 to 20 that are divisible by 3 or 5.


    
  
Q6.6

Write a program to calculate the average of the list [80, 90, 70, 85, 95] using sum() and len().


    
  
Q6.7

Write a program to check if a year is a leap year using and/or. Test with year = 1900.


    
  
Q6.8

Write a program to print a number pyramid pattern:

1
12
123
1234
12345

    
  

Ready to check your score?

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