What is the difference between a for loop and a while loop.

A while loop is used in situations where we do not know how many times a loop needs to be executed beforehand.A for loop is used where we already know the number of times loopneeds to be executed.For example, imagine we want to create an animation of someone skipping using a rope. A WHILE loop would be useful if you want to create a program that has the animation of someone skipping till the user says stop.A FOR loop would be useful if you know how many times you want the animation of someone skipping to run.

TD

Related Python Mentoring answers

All answers ▸

Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


Ask the user for a number and output the smallest divisor, bigger than one, for the inputted number. Output "Prime" if the number is a prime number.


Why are negative indexes used?