Chapter 6a - For Loops
For Loops
for i in range(10):
print(i)
Lab
- Try chan-+ging from
10
to15
More about Range
range(start, stop, steps)
for i in range(2,12,3):
print("Number "+ str(i))
Exercise: Hello...
Exercise
- Create a program that prints the following using for loops:
- The program prints Hello {n} and the iteration number in {n}
- It itarates 5 times
- Note how it starts from 1 instead of
0
Please solve it here:
Placing Napkins
- The following program asks the amount of tables to setup.
- The for each table it:
- places the plate.
- the napkin.
- Tells the the number of the table set.
For example for the first table it would print.
Plate placed
Napkin placed
Table has been set for 1
tip
Modify the program so that It also adds:
- Silverware preparations
- Glass of water preparations for each table.
So instead of just doing the following for the first table:
Plate placed
Napkin placed
Table has been set for 1
It should be doing this:
Plate placed
Silverware placed
Napkin placed
Glass of water placed
Table has been set for 1
*** 🙋♀️ Expected Output