Please answer the following questions to assess your level: How many times is the following loop executed?1234 i=100 while(i<=200): print(i) i+=20
Question
Please answer the following questions to assess your level: How many times is the following loop executed?1234 i=100 while(i<=200): print(i) i+=20
Solution
The loop starts with i = 100 and increments i by 20 in each iteration until i is no longer less than or equal to 200.
Here are the values of i for each loop iteration:
- 100
- 120
- 140
- 160
- 180
- 200
So, the loop is executed 6 times.
Similar Questions
How many times will the following "for loop" iterate?for i in range(5): print(i)
How many times will the loop run?i=2while(i>0): i=i-1
What will be the output of the following program?while i < 20: print(i) i += 1
How many times is the body of the loop executed in the code above?
What will be the output of the following program in Python/for i in range(4): if i==2: print(i) i=10
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.