''' DS2000 Spring 2023 Sample code from class - practice with loops Uncomment the loop you want to run to see how it goes! (Shortcut for un-commenting. Select the code you want and hit command-1 or ctrl-1.) ''' import random def main(): # Loop 1 i = 1 while i < 4: print(i * 2) i += 1 print("done!\n\n") # # Loop 2 # i = 1 # while i < 4: # print(i * 2) # # Loop 3 # num_tix = int(input("How many Taylor Swift tickets?\n")) # while num_tix < 1 or num_tix > 6: # num_tix = int(input("Enter again\n")) # print("Thank you!\n\n") # # test user input: -1, 7, 1, 6, 2, -10 # # Bonus extra loop 4, cut the value of i in half each time # i = 32 # count = 0 # while i > 1: # i = i // 2 # count += 1 # print("Loop ran", count, "times.\n\n") # # Bonus extra loop 5, what happens when the condition is random # total = 0 # count = 0 # while total < 100: # value = random.randint(1, 100) # total += value # count += 1 # print("Ended with total =", total, "and the loop ran", count, "times!") main()