2. Which symbol is used for assignment in most languages?
The equals sign =
assigns a value to a variable. For example: x = 5
.
3. What does an if
statement do?
An if
statement checks a condition. If it's true, it runs the code inside it. Otherwise, it skips it.
4. Which of these is a string?
A string is a sequence of characters, usually surrounded by quotes. "hello" is a string.
5. What does a loop do?
Loops allow you to repeat a block of code multiple times. Great for tasks like counting or processing lists.
6. What is the output of this code?
x = 5
print(x + 2)
x + 2
is 5 + 2
, which equals 7. Python does the math for you.
7. Which of these is a boolean literal in most languages?
True
is the actual boolean value in most languages. The others are strings or numbers.
8. What does the print()
function do?
print()
sends output to the screen. It's a key tool for debugging and interacting with users.
9. What is a comment used for in code?
Comments help explain what your code is doing. They're ignored by the computer, but read by humans.
10. What type of value is 3.14
?
A float
is a number with a decimal point, like 3.14. Integers don’t have decimals.