17.9k views
10 votes
Describe a situation in a program where you could write and use a "for loop".​

User Atott
by
5.1k points

2 Answers

3 votes
Suppose you want to display even numbers on different lines on the web page your can use for loop.
Another example: if you want to display asterisk (*) 10 times on different lines without using document.write or console.log 10 times. Then u can use for loop…

I hope this helps…
User Nishit
by
4.3k points
3 votes

Answer: You can use a for loop for situations such as a questionnaire, data collection etc.

Step-by-step explanation:

A 'For Loop' is a loop variable. As I said before, you can use it in instances such as questionnaires and data collection. To use a For Loop in Python simply type "for [VARIABLE] in range([HOW LONG YOU WANT THE LOOP TO GO]):. Indentation is key for this, so remember to always end this line of code with a colon.

User Strave
by
5.0k points