Which symbol begins a comment in Python?
The hash symbol (#) begins a comment:
# This is a comment
What does the print() function do?
The print() function displays information on the screen.
Is Python case-sensitive?
Yes, Python is case-sensitive.
What is the output?
name = "Ayna"
print("Hello ", name)
A. Hello name B. Hello Ayna
C. "Hello", "Ayna" D. Ayna Hello
B. Hello Ayna
What does the operator != mean?
!= means not equal to.
What is a loop?
A loop repeats a block of code.
What data type is "Hello"?
String
What is a while loop used for?
A while loop repeats code while a condition remains True.
What is the output?
age = 14
if age >= 13:
print("Teenager")
else:
print("Child")
A. Child B. 14 C. Teenager D. An error occurs
C. Teenager
What is a for loop used for?
A for loop repeats code for each item in a sequence or a specific number of times.
What data type is True?
True is a Boolean (bool)
What is the result of 2 ** 3?
The result of 2 ** 3 is 8.
What is the difference between = and ==?
= assigns a value to a variable, while == compares two values.
What is the output?
for number in range(1, 4):
print(number)
A. 1 2 3 B. 1 2 3 4
C. 0 1 2 3 D. 4
A. 1 2 3
What values does range(5) generate?
0, 1, 2, 3, 4
Name four common Python data types
Four common data types are:
How can you convert "10" into an integer?
Use int() to convert "10" into an integer:
number = int("10")
What do elif and else mean?
elif checks another condition if the previous one is false. else runs when none of the conditions are true.
What is the output?
colors = ["red", "blue", "green"]
print(colors[1])
A. red B. blue
C. green D. An error occurs
B. blue
What does break do inside a loop?
break immediately stops the loop.
What does the % operator calculate?
The % operator finds the remainder after division.
print(10 % 3)
Output:
1
What could cause an infinite loop?
An infinite loop can happen when its condition never becomes False
number = 1
while number <= 5: print(number)
What is the output?
x = 5
x = x + 2
print(x * 2)
14