Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE.
2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.

Join 36000+ teachers and students using TTIO.

Iteration

Iteration is just referring to loops. Loops involve the repetition of code. 

Python has two primitive loop commands:

  • while loops
  • for loops

Teaching/Learning Presentation

PPT #2: Teaching/Learning Presentation with tasks

While Loop Example

Print i as long as i is less than 6:

i = 1
while i < 6:
  print(i)
  i += 1

For Loop Example

Print each fruit in a fruit list:

fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x)

www.teachyourselfpython.com