Advertisement
Guest User

Q1

a guest
May 1st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import uuid
  2. import os
  3. import random as r
  4.  
  5. '''
  6. This code was written for quiz no. 1 on the 30/04/2018
  7.  
  8.  
  9. '''
  10.  
  11.  
  12. GENERATED_UUID = str(uuid.uuid4())
  13. username = os.getlogin()
  14.  
  15. print("***************************************")
  16. print(" Hello {} ".format(username))
  17. print(" Secret {} ".format(GENERATED_UUID))
  18. print("***************************************")
  19.  
  20.  
  21. while True:
  22.  
  23. user_password = input("Please enter the code: ")
  24.  
  25. if user_password == GENERATED_UUID[-4:]:
  26. is_guessed = False
  27. random_number = r.randint(0, 10)
  28. print("[---------- You got the code right.")
  29. print("[---------- Now let's play the guessing game.")
  30.  
  31. while is_guessed != True:
  32. guessed_number = input("Enter a random number from a certain range: ")
  33. guessed_number = int(guessed_number)
  34. if guessed_number == random_number:
  35. is_guessed = True
  36. print("You have cracked the program. Good job.")
  37. print("Submit the working code to the TrainerPS.")
  38. break
  39. else:
  40. print("Please try again...")
  41.  
  42. else:
  43. print("Wrong password. Take a look at the secret for a hint.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement