Loops 1 (for)

Questions to introduce writing loops.
  1. Print out the following without repeating code:

     1 Mississippi
     2 Mississippi
     3 Mississippi
     4 Mississippi
     5 Mississippi
     6 Mississippi
     7 Mississippi
     8 Mississippi
     9 Mississippi
     10 Mississippi
    
  2. Print out a launch sequence:

     10
     9
     8
     7
     6
     5
     4
     3
     2
     1
     blast off
    
  3. There are 15 people on the bus so far. The bus stop has seven more. Print out the number of people on the bus as each person gets on.

     16 people
     17 people
     18 people
     19 people
     20 people
     21 people
     22 people
    
  4. There are 85 pieces of candy in a loot box. Ask how many people are in the class, then show how many candies are left after each person takes one.

     How many people are in your class? 14
     person 1 takes a candy and there are 84 candies left
     person 2 takes a candy and there are 83 candies left
     person 3 takes a candy and there are 82 candies left
     person 4 takes a candy and there are 81 candies left
     person 5 takes a candy and there are 80 candies left
     person 6 takes a candy and there are 79 candies left
     person 7 takes a candy and there are 78 candies left
     person 8 takes a candy and there are 77 candies left
     person 9 takes a candy and there are 76 candies left
     person 10 takes a candy and there are 75 candies left
     person 11 takes a candy and there are 74 candies left
     person 12 takes a candy and there are 73 candies left
     person 13 takes a candy and there are 72 candies left
     person 14 takes a candy and there are 71 candies left
    
  5. Red house has a random number of people in it, currently between 1 and 100. Have the computer pick that random number and print it then. The bell rings and they all leave, one at a time. Count how many people are left as each one leaves.

     Red house has a random number of people between 1 and 100.
     Right now it has 20 people
     20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 all gone
    
  6. Ask the human what the capacity for a dance hall is. Everyone comes to this dance with a partner. The hall starts empty and couples start to arrive. Print how many people are in the hall after each pair arrives. Stop when the hall is full.

     What is the capacity of the dance hall? 47
     2 people in the hall
     4 people in the hall
     6 people in the hall
     8 people in the hall
     10 people in the hall
     12 people in the hall
     14 people in the hall
     16 people in the hall
     18 people in the hall
     20 people in the hall
     22 people in the hall
     24 people in the hall
     26 people in the hall
     28 people in the hall
     30 people in the hall
     32 people in the hall
     34 people in the hall
     36 people in the hall
     38 people in the hall
     40 people in the hall
     42 people in the hall
     44 people in the hall
     46 people in the hall
    
  7. You are a restaurant server saving money for a new pair of shoes. The shoes cost $450. You have only 14 days to save before the shoes go out of stock. You earn $7.30 per hour. You work 2 hours a night because you have to study. Every day you get a random amount of tips between $10 and $20. Print out how much you have after each day. At the end print out either “YAY I BOUGHT THEM” or “NOOOO THEY ARE GONE NOW”.

     Day 1 earned $34.6 including $20 in tips... saved $34.6 so far
     Day 2 earned $30.6 including $16 in tips... saved $65.2 so far
     Day 3 earned $34.6 including $20 in tips... saved $99.80000000000001 so far
     Day 4 earned $27.6 including $13 in tips... saved $127.4 so far
     Day 5 earned $32.6 including $18 in tips... saved $160 so far
     Day 6 earned $30.6 including $16 in tips... saved $190.6 so far
     Day 7 earned $33.6 including $19 in tips... saved $224.2 so far
     Day 8 earned $31.6 including $17 in tips... saved $255.79999999999998 so far
     Day 9 earned $33.6 including $19 in tips... saved $289.4 so far
     Day 10 earned $33.6 including $19 in tips... saved $323 so far
     Day 11 earned $31.6 including $17 in tips... saved $354.6 so far
     Day 12 earned $27.6 including $13 in tips... saved $382.20000000000005 so far
     Day 13 earned $29.6 including $15 in tips... saved $411.80000000000007 so far
     Day 14 earned $30.6 including $16 in tips... saved $442.4000000000001 so far
     YAY I BOUGHT THEM
    
Last modified August 18, 2023: 2022-2023 End State (7352e87)