Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define a function that display a nursery rhyme
- def nursery_rhyme():
- print(" If you're happy and you know it, clap your hands. \n If you're happy and you know it, clap your hands.")
- print(" If you're happy and you know it, then your face will surely show it. \n If you're happy and you know it, clap your hands.")
- #define a function, that takes input(name) and the sings happy bday to (name)
- def sing_bday():
- name = input(" What is the name of the person celebrating their birthday ")
- print(" Happy birthday to you ")
- print(" Happy birthday dear {},happy birthday to you!!!".format(name))
- #define a function that creates a password,prompts user for number of characters,generates random password,then asks to input the password
- def password():
- import random
- length = input("How many characters must the password have ?")
- returnpassword = ""
- for i in range(int(length)):
- answer = random.choice("abcdefghijklmonpqrstuvwxijz1234567890")
- returnpassword = returnpassword + (answer)
- print(returnpassword)
- question = input(" Enter the password >")
- if question == returnpassword:
- print(" Congrats unlocked")
- else:
- print(" Sorry failed")
- #while loop, choose 1 of 3 options
- while True:
- print(" option 1 is nursery rhyme \n option 2 is birthday song \n option 3 is password generator ")
- decision = input(" What would you like to do? 1, 2, or 3 >")
- if decision == str(1):
- nursery_rhyme()
- elif decision == str(2):
- sing_bday()
- elif decision == str(3):
- password()
- else:
- print(" invalid argument")
Add Comment
Please, Sign In to add comment