What is a variable in programming?
a named location used to store data
Name one numeric data type in Python.
int or float
What does the + operator do with numbers?
Adds them together.
How do you get input from the user in Python?
Use the input() function
How do you write a single-line comment in Python?
Use # before the comment
How do you assign a value of 5 to a variable called x?
x = 5
What data type is "hello"?
str (string)
What does the * operator do with strings?
Repeats the string. Example: 'a'*3 is 'aaa'
How do you display output in Python?
Use the print() function
Are comments run by the Python interpreter?
No, they’re ignored.
What happens if you try to use a variable that hasn’t been defined?
You get a NameError.
What is the type of the value 3.14?
float
What is the result of 5 % 2?
1 (modulus: remainder of division)
What data type does input() always return?
A string (str)
Why are comments useful?
They help explain code for humans.
What is the difference between = and ==?
= assigns a value, == compares.
What function do you use to check the type of a variable?
type()
What does // mean in Python?
Floor division (no remainder)
How would you get a number from the user and store it in a variable?
x = int(input("Enter a number: "))
How do you write a multi-line comment?
Use triple quotes (''' or """)
Can variable names start with a number in Python?
No, variable names can’t start with numbers.
What is the result of type(True)?
<class 'bool'>
What does != mean?
Not equal
How do you print multiple values at once?
Use commas in print(): print("Hi", name)
Write a comment above a line of code that adds two numbers.
# This line adds two numbers