Python Quiz Prep

Grade 8 Cambridge Curriculum

Python Programming Flashcards

Click on the card to flip it and see the definition.

Variable

Click to flip

A named storage location in memory that holds a value

Card 1 of 30

Python Coding Questions

Test your knowledge with these coding questions.

Question 1: Variables and Data Types

What will be the output of the following code?

x = 5
y = "10"
print(x + int(y))
510
15
Error
5

Question 2: For Loops

What will this code output?

for i in range(3):
    print(i * 2)
0 2 4
2 4 6
0 1 2
1 2 3

Question 3: Functions

What will this function return when called with calculate_area(4, 5)?

def calculate_area(length, width):
    return length * width
9
20
Error
None

Question 4: Lists

What will be the value of my_list after this code executes?

my_list = [1, 2, 3]
my_list.append(4)
my_list.pop(0)
[1, 2, 3]
[2, 3, 4]
[1, 2, 3, 4]
[2, 3]

Completed: 0/4

Debugging Practice

Find and fix the errors in these code snippets.

Debug 1: Function Error

The following code should calculate the area of a rectangle, but it contains an error. Identify and fix it.

def calculate_area(length, width):
    area = lenght * width # Error here
    return area

result = calculate_area(5, 3)
print(result)

What's wrong with this code?

Debug 2: While Loop

This while loop should print numbers from 1 to 5, but it runs forever. Fix the code.

i = 1
while i < 5:
    print(i)
    # Missing increment statement

What's missing in this code?

Debug 3: List Index Error

This code tries to access an element in a list, but it causes an error.

fruits = ["apple", "banana", "cherry"]
print(fruits[3]) # Error here

What's the problem with this code?

Debug 4: Syntax Error

This code has a syntax error. Find and fix it.

if x > 5
    print("x is greater than 5")

What's missing in this code?

Completed: 0/4

Your Progress

Track your learning progress across all sections.

Overall Progress: 0%

Flashcards: 0/30 reviewed

Coding Questions: 0/4 completed

Debugging: 0/4 completed