Computer Science, asked by Vishalkumarshow123, 12 hours ago

write about the uses of loops in Python
please answer it fast ​

Answers

Answered by anitaagarwal1290
1

Answer:

Python for loops are used to loop through an iterable object (like a list, tuple, set, etc.) and perform the same action for each entry.

Explanation:

For example, a for loop would allow us to iterate through a list, performing the same action on each item in the list.

Hope this helps you :-)

Please mark my answer as brainliest.

Answered by Anonymous
6

Answer:

Looping is the act of repeating something until a certain condition is satisfied. Python loops are mainly used to iterate through arrays or repeat cօde specific amount of times. It's saves our time and execute cօde repeatedly.

Explanation:

Suppose that, someone give you a task to print a text 5 times, you would do this:

print("Text")

print("Text")

print("Text")

print("Text")

print("Text")

Now what will you do if you have to print a text 1000 times? Would you do the same way to print the text 1000 times and the answer is no, right?

Now come the rescuer called LOOP (for loop):

for i in range(1000):

print("Text")

Since i starts with 0, the "Text" print out 1000 times. i goes from 0 to 1 to 2 to 3 to 4 to 5 to ... to 1000 (till 1000). i begins at an index of 0, it works perfectly.

Now come the rescuer called LOOP (while loop):

a = 1

while a <= 1000:

print("Text")

a = a + 1

With continued use you will notice that "for" is used more when you have a specific time for repeat it over and over again. A good example is if you want to count from zero to ten.

When something is unknown, "while" is used more often. You don't know when it will be valid, the process will be repeated until it is valid.

#Learn more:

Write a program to display the message "Happy Birthday" on screen for 15 times

- brainly.in/question/45284638

Similar questions