What is the keyword used to check a condition in Python?
if
What data type is used for numbers without decimals in Python?
int
What function is used to display output to the console?
print()
How do you create a variable named age with a value of 15?
age = 15
What function is used to get user input in Python?
input()
What is the keyword to specify an alternative condition in Python?
elif
What is the data type of the value "Hello, World!" in Python?
str (string)
What is the output of this code: print("Hello", "World")
Hello World
What is the value of x after this code:
x = 10
x = 5
5
How do you store user input as a variable called name?
name = input()
What keyword would you use if you want to execute code when all conditions are false?
else
What is the data type for a number with decimals, like 3.14
float
Assume you have a variable named "name" which is equal to your name. How would you print "Hello name"?
print("Hello", name)
How do you assign the same value to two variables a and b in one line?
a = b = 10
What does this code do?
age = input("Enter your age: ")
print("You are", (age), "years old")
It asks the user for their age and then prints a sentence with their input.
What is the result of this code:
if 5 > 3:
print("Yes")
else:
print("No")
Yes
How do you convert a string s = "10" into an integer?
int(s)
What is the difference between print(5) and print("5")?
The first prints the integer 5, while the second prints the string "5".
What is the result of this code?
x = 3
y = x + 2
print(y)
5
How do you make sure the input is an integer?
Use int(input())
How do you write an if statement that checks if a variable x is greater than 10 and less than 20?
if 10 < x < 20:
What is the output of this code:
x = "5"
y = 2
print(int(x) * y)
10
How can you print the following output using only one print() statement and concatenation(using +)?
Hello World Python
print("Hello" + " " + "World" + " " + "Python")
What is the best practice for naming variables that store a person's first name?
Use meaningful variable names like first_name (snake_case for readability).
What happens if you try to convert a non-numeric string like "abc" to an integer using int()?
Raises a ValueError