Syntax
Errors
Data Types
Inputs
Vocab
100

What symbol is used to start a Python comment?

#

100

What type of error is caused by forgetting to close a string with quotes?

Syntax Error

100

What data type is the result of this code? 

x = 5 + 3.2

float

100

Write a Python program to ask the user for their age and store it in a variable.

age = input("How old are you? ")

100

What is a variable in Python?

A variable is a container for storing data values.

200

What will this code print?

print("Hello" + "World")

HelloWorld (No space between words).

200

What type of error will this code produce, and why? 


x = 5 

y = "7" 

z = x + y

Syntax TypeError, because you can’t add an integer (x) to a string (y).

200

Convert the string "25" into an integer and store it in a variable.

x = int("25")

200

Write a program that asks the user for their name and then prints a greeting like this: 

Hello, [name]!

name = input("What is your name? ") print("Hello, " + name + "!")

200

What does the int() function do in Python?

Converts a value into an integer.

300

Fix the syntax error in this code:

print "Welcome to Python!"

print ("Welcome to Python!")


Add parentheses:

300

Identify and fix the error in this code: 

print("The answer is: " + 42)

print("The answer is: " + str(42))


Convert the integer to a string:  

300

What will this code print? 

x = 5 y = "5" print(x * y)

55555 (repeats the string 5 times).

300

Write code to ask the user for two numbers and print their sum.

x = input("Enter the first number: "))

y = input("Enter the second number: ")

print("The sum is: " + int(x) + int(y)  

300

What is the term for fixing errors in your code?

Debugging.

400

Rewrite this line of code so it runs without error: 


name = input("What is your name?"  

name = input("What is your name?")


Close the parentheses:

400

Rearrange the code so it runs correctly: 

print("The sum is: ", x + y) 

x = 5 

y = 10  

 x = 5 

y = 10 

print("The sum is: ", x + y) 

400

What will this code print, and why? 

x = "7" * 3 

print(x)

It will print 777 because the string "7" is repeated 3 times.

400

 Write a program that asks the user for two numbers, multiplies them, and prints the result. 

 

x = input("Enter the first number: "))

y = input("Enter the second number: ") 

print("The product is: " + int(x) * int(y))

400

What does the input() function do in Python?

Prompts the user for input and returns it as a string.

500

Write a Python program that stores your first name and last name in variables and prints them in the format: LastName, FirstName.

first_name = "YourFirstName" 

last_name = "YourLastName" 

print(last_name + ", " + first_name)

500

Why does the following code crash? How would you fix it?

value = int(input("Enter a number: ")) 

print("Your number is " + value)

Fix it by converting the integer to a string: 


value = int(input("Enter a number: ")) 

print("Your number is " + str(value))

500

Explain what the following code does: 

x = float("25") + int("30")

Converts the string "25" to a float, converts "30" to an integer, and adds them. The result is 55.0 (a float).

500

Write a program that asks the user for their name and age, then prints this sentence: 

[Name] is [Age] years old.

name = input("What is your name? ") 

age = input("How old are you? ") 

print(name + " is " + age + " years old.")

500

What is the difference between a function and a variable?

  • A variable stores data.
  • A function is a block of code that performs a specific task and can be reused.
M
e
n
u