music = "yes" while music == "yes": print("Playing song") music = input("Do you want to repeat the song? (yes/no) ") print("Song stopped") song = "yes" count = 0 while song == "yes" and count < 3: print("Playing song") count += 1 song = input("Do you want to repeat the song? (yes/no) ") print("Song stopped") password = "password" while password != "secret": password = input("Enter the password: ") print("Password accepted") """ Let us now write code to do the following: • Use while loop to display numbers from 1 to 20 in ascending order • Use while loop to display numbers from 20 to 1 in descending order """ i = 1 while i <= 20: print(i) i += 1 print("Done") j = 20 while j >= 1: print(j) j -= 1 print("Done") """ Let us now write code to do the following: • Use while loop to display numbers from 3 to 30 in increments of 3 • Use while loop to display numbers from 40 to 4 in decrements of 4. """ k = 3 while k <= 30: print(k) k += 3 print("Done") l = 40 while l >= 4: print(l) l -= 4 print("Done") """ """ m = 1 sum = 0 while m != 0: m = int(input("Enter a number: ")) sum += m print("The sum is", sum) """ Use for loop to display numbers from 1 to 10 in ascending order • Use for loop to display numbers from 10 to 1 in descending order """ print("-----break------") for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: if i == 3: continue if i == 7: break print(i) print("Done") for j in [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]: print(j) print("Done") """ Use for loop with the range()function to display numbers from 5 to 50 in increments of 5 • Use for loop with the range()function to display numbers from 60 to 6 in decrements of 6. """ for k in range(5, 51, 5): print(k) print("Done") for l in range(60, 5, -6): print(l) print("Done") """ Prompt user to enter a word • Use for loop to display each letter of the word entered by the user """ word = input("Enter a word: ") for i in word: print(i) print("Done")