Presentation is loading. Please wait.

Presentation is loading. Please wait.

Some Common Issues: Iteration

Similar presentations


Presentation on theme: "Some Common Issues: Iteration"— Presentation transcript:

1 Some Common Issues: Iteration
Damian Gordon

2 WHILE Loops

3 # PROGRAM Print1To5: a = 1 while a
# PROGRAM Print1To5: a = 1 while a != 6: # DO print(a) a = a + 1 # ENDWHILE; # END.

4 # PROGRAM Print1To5: a = 1 while a
# PROGRAM Print1To5: a = 1 while a != 6: # DO print(a) a = a + 1 # ENDWHILE; # END. >> 1 2 3 4 5

5 FOR Loops

6 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a) # ENDFOR; # END.

7 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a) # ENDFOR; # END.
>> 1 2 3 4 5

8 Printing Multiple Values
FOR Loops Printing Multiple Values

9 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a, a+1) # ENDFOR; # END.

10 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a, a+1) # ENDFOR; # END.
>> 1 2 2 3 3 4 4 5 5 6

11 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a, a+1, a+10) # ENDFOR; # END.

12 # PROGRAM Print1To5For: for a in range(1,6): # DO print(a, a+1, a+10) # ENDFOR; # END.
>> 1 2 11 2 3 12 3 4 13 4 5 14 5 6 15

13 Incrementing by different values
FOR Loops Incrementing by different values

14 # PROGRAM Print-For: for a in range(1,6,1): # DO print(a) # ENDFOR; # END.

15 # PROGRAM Print-For: for a in range(1,6,1): # DO print(a) # ENDFOR; # END.

16 # PROGRAM Print-For: for a in range(1,6,1): # DO print(a) # ENDFOR; # END.
>> 1 2 3 4 5

17 # PROGRAM Print-For: for a in range(1,6,2): # DO print(a) # ENDFOR; # END.

18 # PROGRAM Print-For: for a in range(1,6,2): # DO print(a) # ENDFOR; # END.
>> 1 3 5

19 # PROGRAM Print-For: for a in range(1,6,3): # DO print(a) # ENDFOR; # END.

20 # PROGRAM Print-For: for a in range(1,6,3): # DO print(a) # ENDFOR; # END.
>> 1 4

21


Download ppt "Some Common Issues: Iteration"

Similar presentations


Ads by Google