PYTHON_101 | EXAMPLE 3 - LOOPS.PY
SMARS Learning Platform
57% Complete
PYTHON_101 | EXAMPLE 3 - LOOPS.PY
Type of the program below into your Python Editor
# Loops
# Python_101
# For loop
for i in range(1, 11):
print("i is",i)
# set our variables to the start condition
test = False
count = 1
# go round the loop 10 times
while not test:
print("loop", count)
count = count + 1
if count == 11:
test = True
Save the file and then run it either from the editor or from the command line:
python3 loops.py
Downloads |