AlgoMaster Logo

Basic Syntax - Quiz

Last Updated: January 3, 2026

Basic Syntax Exercises

31 quizzes

1
Code Completion

Complete the statement so total_price stores the product of quantity and unit_price.

python
1
total_price = quantity unit_price

Click an option to fill the blank:

2
Code Completion

Complete the statement so user_age is converted from text input to an integer number.

python
1
user_age = int()

Click an option to fill the blank:

3
Code Completion

Complete the statement so the length of the message string is stored in msg_length.

python
1
msg_length = (message)

Click an option to fill the blank:

4
Multiple Choice

Which of the following is a valid variable name in Python?

5
Multiple Choice

Which data type is best for storing a user's full name?

6
Multiple Choice

What is the type of the value 3.0 in Python?

7
Multiple Choice

Which expression performs integer (floor) division in Python?

8
Multiple Choice

What is the result type of 5 + 2.5 in Python?

9
Multiple Choice

What does the input() function return by default?

10
Multiple Choice

Which of these lines is a valid single-line comment in Python?

11
Multiple Choice

What happens if you write code inside an if statement without indenting it?

12
Multiple Choice

Which of the following is a Python keyword?

13
Multiple Choice

Which identifier follows Python naming conventions for a variable storing a user's email?

14
Multiple Choice

Which operator checks if two values are not equal?

15
Sequencing

Order the steps to read an integer age from the user and store it in age_years.

Drag and drop to reorder, or use the arrows.

16
Sequencing

Order the steps to calculate and display the area of a rectangle using variables.

Drag and drop to reorder, or use the arrows.

17
Output Prediction

What is the output of this code?

1length = 4
2width = 2
3area = length * width
4print(area)
18
Output Prediction

What is the output of this code?

1value = 7
2print(type(value) == int)
19
Output Prediction

What is the output of this code?

1a = 5
2b = 2
3result = a // b + a % b
4print(result)
20
Output Prediction

What is the output of this code?

1text = "5"
2number = 3
3combined = text * number
4print(combined)
21
Output Prediction

What is the output of this code?

1x = 0.1 + 0.2
2rounded = round(x, 1)
3print(rounded)
22
Bug Spotting

Find the bug in this code that reads an age and prints it in 10 years.

Click on the line(s) that contain the bug.

python
1
age_text = input("Enter your age: ")
2
age_number = age_text
3
future_age = age_number + 10
4
print(f"In 10 years you will be {future_age}")
23
Bug Spotting

Find the bug in this code that calculates the average of two numbers.

Click on the line(s) that contain the bug.

python
1
first_number = 10
2
second_number = 20
3
sum_numbers = first_number + second_number
4
average = sum_numbers / 0
5
print(average)
24
Matching

Match each numeric type with a suitable example value.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

25
Matching

Match each concept with its description.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

26
Fill in the Blanks

Complete the code to read a product price from the user as a float and print it with a label.

python
1
price_text = input("Enter product price: ")
2
price_number = (price_text)
3
print("Price:", )

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the code to calculate the total number of items from two integer variables and display it.

python
1
box_count = 3
2
items_per_box = 4
3
total_items = box_count items_per_box
4
print()

Click an option to fill blank 1:

28
Fill in the Blanks

Complete the code so that a comment explains the calculation and the result of a+b is printed.

python
1
This line adds two numbers
2
a = 5
3
b = 7
4
(a + b)

Click an option to fill blank 1:

29
Fill in the Blanks

Complete the code so that status is True when score is at least 50 and it is printed.

python
1
score = 65
2
status = score 50
3
print()

Click an option to fill blank 1:

30
Hotspot Selection

Click the line that will raise an error because of an invalid identifier.

Click on the line to select.

python
1
user-name = "alex"
2
print(user-name)
31
Hotspot Selection

Click the line that causes a runtime error.

Click on the line to select.

python
1
items = []
2
first_item = items[0]
3
print(first_item)