COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which type of loop runs a set number of times?
|
Indefinite
|
|
While
|
|
Infinite
|
|
For
|
Explanation:
Detailed explanation-1: -The for loop runs for a fixed amount of times, while the while loop runs until the loop condition changes.
Detailed explanation-2: -To loop through a set of code a specified number of times, we can use the range() function, The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.
Detailed explanation-3: -Answer: (c) For The for loop statement is another most commonly used loop statement. It is an entry controlled loop. You should use it when you need to repeat something for some predefined or fixed number of times.
There is 1 question to complete.