AlgoMaster Logo

Introduction to Python - Quiz

Last Updated: January 3, 2026

Introduction to Python Exercises

32 quizzes

1
Code Completion

Complete the code so it displays the type of the value stored in value_info

python
1
print(type(value_info.))

Click an option to fill the blank:

2
Code Completion

Complete the code so it prints how many characters are in course_title

python
1
print(len())

Click an option to fill the blank:

3
Code Completion

Complete the code so the expression checks whether value is not equal to 0

python
1
is_non_zero = (value 0)

Click an option to fill the blank:

4
Multiple Choice

Which statement best describes Python as a language?

5
Multiple Choice

Who created Python?

6
Multiple Choice

What does it mean that Python is dynamically typed?

7
Multiple Choice

Which version introduced major, intentionally incompatible changes to clean up Python's design?

8
Multiple Choice

Which feature of Python makes it especially suitable for rapid prototyping?

9
Multiple Choice

Which field is Python particularly strong in compared to JavaScript?

10
Multiple Choice

What is the main role of pip in Python development?

11
Multiple Choice

What is the typical file extension for a Python source file?

12
Multiple Choice

In a Python script, what does a line starting with # represent?

13
Multiple Choice

Which Python interpreter implementation is the reference implementation written in C?

14
Multiple Choice

In interactive Python mode, what typically indicates the interpreter is ready for a new statement?

15
Multiple Choice

Why is Python often considered beginner-friendly?

16
Sequencing

Order the steps to create and run a simple Python script that prints a message.

Drag and drop to reorder, or use the arrows.

17
Sequencing

Order the steps describing how the Python interpreter executes your script.

Drag and drop to reorder, or use the arrows.

18
Output Prediction

What is the output of this code, illustrating dynamic typing?

1label = "Version"
2label = label + " 3"
3print(label)
19
Output Prediction

What is the output of this code showing list comprehension usage?

1values = [1, 2, 3]
2squares = [number * number for number in values]
3print(squares)
20
Output Prediction

What is the output of this code related to object-oriented programming?

1class Course:
2    def __init__(self, title):
3        self.title = title
4
5python_course = Course("Intro to Python")
6print(python_course.title)
21
Output Prediction

What is the output of this code that uses the math library?

1import math
2angle = math.pi / 2
3result = round(math.sin(angle), 2)
4print(result)
22
Output Prediction

What is the output of this code illustrating interpreter errors at runtime?

1def safe_divide(a, b):
2    if b == 0:
3        return "cannot divide by zero"
4    return a / b
5
6print(safe_divide(10, 0))
23
Bug Spotting

Find the bug in this code that is meant to print a welcome message only for version 3.

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

python
1
version = 3
2
if version = 3:
3
    print("Welcome to Python 3 course")
4
else:
5
    print("Different version")
24
Bug Spotting

Find the bug in this code that intends to show the installed Python packages.

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

python
1
def show_packages():
2
    import pip
3
    packages = pip.list()
4
    print(packages)
25
Matching

Match each Python implementation with its typical host platform or feature.

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

26
Matching

Match each Python feature with its description.

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

27
Fill in the Blanks

Complete the code to print a greeting from a first Python program.

python
1
course_title =
2
(course_title)

Click an option to fill blank 1:

28
Fill in the Blanks

Complete the code to import the math module and print the square root of 16.

python
1
import
2
result = .(16)
3
print(result)

Click an option to fill blank 1:

29
Fill in the Blanks

Complete the code to create a small history dictionary for Python.

python
1
python_history = {
2
"creator": ,
3
"first_release":
4
}
5
print(python_history["creator"], python_history["first_release"])

Click an option to fill blank 1:

30
Fill in the Blanks

Complete the code to compare Python with another language in a simple message.

python
1
language_a = "Python"
2
language_b =
3
comparison = f"{language_a} vs {language_b}"
4
(comparison)

Click an option to fill blank 1:

31
Hotspot Selection

Click the line that actually executes the function using the Python interpreter.

Click on the line to select.

python
1
def greet(name):
2
    message = f"Hello, {name}!"
3
    return message
4
 
5
print(greet("Student"))
32
Hotspot Selection

Click the line where dynamic typing changes the type stored in data.

Click on the line to select.

python
1
data = 10
2
print(type(data))
3
data = "ten"
4
print(type(data))