Advertisement
Guest User

Bath Time 2

a guest
Mar 28th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. import random
  2.  
  3. # List of kids
  4. kids = ['Davidson', 'Gabrielle', 'Shane']
  5.  
  6. # Initializes iteration variables
  7. # "itvar" determines when the while loop will stop
  8. itvar = 0
  9.  
  10. # "three" determines when the loop is at the end of one day
  11. three = -1
  12.  
  13. # "daily" is a list that changes with every iteration
  14. # It will be appended to three times (once per kid) and then be reset
  15. # There is no way it can have a duplicate name
  16. daily = []
  17.  
  18. # This while loop will execute as long as "itvar" is less than 31
  19. # You can make it execute more by changing this number
  20. while itvar < 31:
  21.  
  22.     # If the "three" variable has been incrememted (three times) to 2
  23.     # it will be reset to -1 and the "daily" list will be emptied
  24.     if three == 2:
  25.         three = -1
  26.         daily = []
  27.  
  28.     # Generates a random number
  29.     rand = random.randint(0,2)
  30.  
  31.     # This if statement is there so there can be no duplicate names in the "daily" list
  32.     # It tests if the name at the random index of "kids" is already in the list
  33.     # If a name is successfully appended the "three" variable will be incremented
  34.     if kids[rand] not in daily:
  35.         three += 1
  36.         daily.append(kids[rand])
  37.  
  38.     # This if statement only runs if the "three" variable is at it's last value (2)
  39.     if three == 2:
  40.  
  41.         # The iteration variable is incrememted here
  42.         # This is the variable that only allows this program to print out 31 times
  43.         itvar += 1
  44.  
  45.         # This just prints dashes for formating along with the iteration variable
  46.         print "---------------" + str(itvar)
  47.  
  48.         # This for loop prints out all the names in the "daily" list
  49.         for kid in daily:
  50.             print kid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement