Python Operators + if-else + Loops | 2/100 Days of Python Algo trading

Congratulations on reaching this stage!

If you’re here, it means you’re truly dedicated to mastering Python. Directly below, you’ll find a quiz designed to help you reinforce what you’ve just learned. This isn’t just about recalling facts; it’s about deeply understanding the concepts. Take a moment to answer the questions and see how well you can apply the knowledge from the video. You’re doing great—every question you tackle brings you one step closer to becoming a Python expert!

Day 2: Python Operators + if-else + Loops

1. What are the two main categories of operators in Python?
2. What does the following code output: result = 5 + 3 * 2
3. How do you represent exponentiation (a to the power of b) in Python?
4. What is the output of the following code: x = 10 if x > 5: print("x is greater than 5")
5. What is the correct syntax to start an if-else statement in Python? 
6. How can you add an else block to an if-else statement?
7. What does the following code do?

number = 10

while number > 0:

print(number)

number -= 1
8. How can you exit a loop early in Python?
9. What is the difference between a for loop and a while loop?
10. What is the correct syntax to start a for loop iterating over a list?
11. What does the % operator do in Python?
12. Which comparison operator checks if two values are not equal?
13. How would you check if the variables x and y hold the same value in Python?
14. Which of the following represents the logical "AND" operator in Python?
15. Which statement is used to skip to the next iteration in a loop?
16. What is the output of this code?

for i in range(5):

if i == 3:

break

print(i)
17. What's the output of this code?

x = 5

if x > 2:

print("Bigger")

elif x < 5:

print("Smaller")
18. What's a common use case for a while loop?
19. How would you iterate through the characters in the string "Hello"?
20. What is the purpose of the pass statement in Python?

 

1 thought on “Python Operators + if-else + Loops | 2/100 Days of Python Algo trading”

Comments are closed.