Robotics & Artificial Intelligence
A loop statement is given as:
for i in range(10):
For how many times will the given loop statement be executed?
- none
- 9 times
- 10 times
- infinite
Python Control Flow
2 Likes
Answer
10 times
Reason — The function range(10) generates a sequence of numbers from 0 to 9, which contains 10 values. Hence, the loop will execute 10 times.
Answered By
1 Like
Related Questions
To find the sum of whole numbers up to 10, a loop runs:
- once
- ten times
- eleven times
- any number of times
Using …………… loop, an infinite loop can be created.
- Fixed iterative loop
- while
- for
- all
When a code allows to use one loop inside another loop, known as ……………
- finite loop
- loop in loop
- nested loop
- infinite loop
Predict the output of the following snippet:
m, n = 2, 15 for i in range(1, 5): m = m + 1 n = n - 1 print("m =", m) print("n =", n)