kevinbocky

rhyme_bday_password.py

Jan 26th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #define a function that display a nursery rhyme
  2. def nursery_rhyme():
  3. print(" If you're happy and you know it, clap your hands. \n If you're happy and you know it, clap your hands.")
  4. 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.")
  5.  
  6. #define a function, that takes input(name) and the sings happy bday to (name)
  7. def sing_bday():
  8. name = input(" What is the name of the person celebrating their birthday ")
  9. print(" Happy birthday to you ")
  10. print(" Happy birthday dear {},happy birthday to you!!!".format(name))
  11.  
  12. #define a function that creates a password,prompts user for number of characters,generates random password,then asks to input the password
  13. def password():
  14. import random
  15. length = input("How many characters must the password have ?")
  16. returnpassword = ""
  17. for i in range(int(length)):
  18. answer = random.choice("abcdefghijklmonpqrstuvwxijz1234567890")
  19. returnpassword = returnpassword + (answer)
  20.  
  21. print(returnpassword)
  22. question = input(" Enter the password >")
  23. if question == returnpassword:
  24. print(" Congrats unlocked")
  25. else:
  26. print(" Sorry failed")
  27.  
  28.  
  29. #while loop, choose 1 of 3 options
  30. while True:
  31. print(" option 1 is nursery rhyme \n option 2 is birthday song \n option 3 is password generator ")
  32. decision = input(" What would you like to do? 1, 2, or 3 >")
  33. if decision == str(1):
  34. nursery_rhyme()
  35. elif decision == str(2):
  36. sing_bday()
  37. elif decision == str(3):
  38. password()
  39. else:
  40. print(" invalid argument")
Add Comment
Please, Sign In to add comment