Multiple Choice
What function is used to display output to the screen in Python?
Check Answer
Fill in the Blank
Complete the code to ask the user for their name and store it:
name = ("What is your name? ")
Check Answer
Code Challenge
Write code that prints "Hello, World!" to the screen:
Check Answer
Multiple Choice
What will this code print?
print ("Hello" , "World" )
Check Answer
Debug This Code
This code should ask for a name and greet the user, but it has a bug. What's wrong?
name = input ("Enter your name: " )
print ("Hello, " + Name)
Variable name is wrong case (Name vs name)
Missing quotes around Hello
Should use comma instead of +
input() is used incorrectly
Hint: Python is case-sensitive!
Check Answer
Multiple Choice
Which of the following is a valid variable name in Python?
Check Answer
Fill in the Blank
Complete the code to convert the string "42" to an integer:
text = "42"
number = (text)
Check Answer
Multiple Choice
What will be the value of result after this code runs?
x = 5
y = 3
result = x + y * 2
Check Answer
Code Challenge
Create a variable called age and assign it the value 15:
Check Answer
Multiple Choice
What is the data type of the variable x?
x = "100"
Check Answer
Debug This Code
This code should calculate the total price, but it has a bug. What's wrong?
price = input ("Enter price: " )
quantity = input ("Enter quantity: " )
total = price * quantity
print ("Total:" , total)
Need to convert inputs to int() or float()
Should use + instead of *
Variables need quotes around them
Hint: What data type does input() return?
Check Answer
Multiple Choice
What will this code print?
x = 10
if x > 5 :
print ("big" )
else :
print ("small" )
Check Answer
Fill in the Blank
Complete the code to check if a number is negative:
num = -5
if num 0 :
print ("Negative!" )
Check Answer
Multiple Choice
Which keyword is used for "otherwise if" in Python?
Check Answer
Code Challenge
Write an if statement that prints "Pass" if the variable score is greater than or equal to 60:
Check Answer
Multiple Choice
What will this code print?
age = 15
if age >= 18 :
print ("Adult" )
elif age >= 13 :
print ("Teen" )
else :
print ("Child" )
Check Answer
Debug This Code
This code should check if a number is even, but it has a bug. What's wrong?
num = 4
if num % 2 = 0 :
print ("Even" )
Should use == instead of = for comparison
% is not a valid operator
Hint: = assigns a value, but what compares values?
Check Answer
Multiple Choice
How many times will "Hello" be printed?
count = 0
while count < 3 :
print ("Hello" )
count = count + 1
Check Answer
Fill in the Blank
Complete the code to create a loop that runs while x is not equal to 10:
x = 0
while x 10 :
x = x + 1
Check Answer
Multiple Choice
What keyword immediately exits a while loop?
Check Answer
Code Challenge
Write a while loop that prints numbers from 1 to 5:
Check Answer
Multiple Choice
What will be the value of x after this loop finishes?
x = 1
while x < 10 :
x = x * 2
Check Answer
Debug This Code
This code should print numbers 1 to 5, but it runs forever. What's the bug?
num = 1
while num <= 5 :
print (num)
Missing num = num + 1 to increment the counter
Should use < instead of <=
Hint: If the condition never becomes False, what happens?
Check Answer
Multiple Choice
Which keyword is used to define a function in Python?
Check Answer
Fill in the Blank
Complete the function to return the sum of two numbers:
def add (a, b):
a + b
Check Answer
Multiple Choice
What will this code print?
def greet (name):
print ("Hi " + name)
greet ("Alice" )
Check Answer
Code Challenge
Write a function called double that takes a number and returns it multiplied by 2:
Check Answer
Multiple Choice
What will result be after this code runs?
def multiply (x, y):
return x * y
result = multiply (4 , 5 )
Check Answer
Debug This Code
This function should return the square of a number, but it doesn't work correctly. What's the bug?
def square (n):
n * n
result = square (5 )
print (result)
Missing return keyword before n * n
Should use ** instead of *
Function is called incorrectly
Variable name 'n' is invalid
Hint: How do you send a value back from a function?
Check Answer
Multiple Choice
What does this program do?
def check (n):
if n > 0 :
return "positive"
elif n < 0 :
return "negative"
else :
return "zero"
num = int (input ("Number: " ))
print (check (num))
Checks if a number is positive, negative, or zero
Counts from 1 to the number
Check Answer
Code Challenge
Write a complete program that: 1. Asks the user for their name using input() 2. Creates a function called welcome that takes a name and prints "Welcome, [name]!" 3. Calls the function with the user's name
Check Answer
Code Challenge
Write a function called countdown that takes a number and uses a while loop to print numbers from that number down to 1, then prints "Blast off!":
Check Answer
Debug This Code
This password checker should keep asking until the correct password is entered, but it has a bug. Find the main issue:
def check_password (pw):
if pw = "secret123" :
return True
else :
return False
correct = False
while correct == False :
password = input ("Password: " )
correct = check_password (password)
Uses = instead of == in the if statement
Return statements are wrong
Function is called incorrectly
Hint: Remember the difference between = and ==
Check Answer
Multiple Choice
What will this program print when the user enters 3?
def sum_to_n (n):
total = 0
count = 1
while count <= n:
total = total + count
count = count + 1
return total
num = int (input ("Enter number: " ))
print (sum_to_n (num))
Check Answer
Code Challenge
Write a complete program that: 1. Creates a function called is_even that takes a number and returns True if it's even, False if odd 2. Uses a while loop to ask the user for numbers 3. For each number, prints whether it's even or odd 4. Stops when the user enters 0
Check Answer