Indefinite (while) loops
Copy this into a Python file and add the specified code under each comment. For testing purposes, you can comment out working parts as you go (surround the lines with """).
""" This is how you comment out a whole block of stuff. """ # write python code to... # print the numbers 5 to 17, using a while loop # print the numbers from 6 down to -8, counting by twos, using a while loop # print the characters from c to m, using a while loop # given these three lists, print out the first item from each on one line, # then the second from each on one line, all the way to the end list1 = [1,2,3,4,5,6,7,8,9,10] list2 = ['a','b','c','d','e','f','g','h','i','j'] list3 = ['z','y','x','w','v','u','t','s','r','q'] # e.g. # 1az # 2by # 3cx # etc. # get a number from the user that is greater than 10 (keep asking until they get it right) # keep asking the user for the "secret word" until they type "shamu" # using a while loop, get numbers from the user and keep a running sum # when the sum reaches 100, quit and print the sum # do it again (same problem as above), only ask the user beforehand how many # numbers they want to enter # quit and print the sum when you get to that many numbers *or* the sum hits 100