- Run Idle on your machine
python3
- Write a
while
loop
>>> numb = 0
>>> while numb < 10:
... numb = numb + 1
...
>>> numb
- Write a
while
loop to add the numbers from 1 to 100
>>> num = 0
>>> total = 0
>>> while num <= 100:
... num = num + 1
... total = total + num
...
>>> total
5151
- Write a data validation loop
>>> done = False
>>> while not done:
... num = int(input('Please enter a number greater than 0: '))
... if num > 0:
... done = True
... else:
... print(num, 'is not greater than 0')
...
- Write an infinite loop
>>> while True:
... print("Are we there yet?")
You many have to hit Control C many times to stop this loop.