Answers Already Passed
How do you make a decision in Python based on multiple conditions?
a) Use only if statements
✔✔b) Use if, elif, and else statements
c) Use while loops
d) Use if statements only with one condition
What is the purpose of the `else` statement in Python?
a) It runs code only if the condition is true
✔✔b) It runs code if all preceding conditions are false
c) It repeats a block of code
d) It checks the type of a variable
Which operator checks if two values are equal in Python?
a) !=
✔✔b) ==
c) <
1
,d) >
What will the following code output?
```python
x=5
if x == 5:
print("Five")
else:
print("Not Five")
```
✔✔a) Five
b) Not Five
c) Error
d) Nothing
How do you create a loop that repeats a specific number of times?
a) repeat n times:
✔✔b) `for i in range(n):`
2
, c) while n times:
d) repeat for n times:
What is the result of the expression `5 > 3`?
✔✔a) True
b) False
c) Error
d) None
What is the purpose of the `elif` statement?
a) It ends the program
✔✔b) It checks another condition if the first is false
c) It repeats a block of code
d) It skips the next condition
How do you check if a string contains a specific substring?
a) `if string == substring:`
✔✔b) `if substring in string:`
3