Advertisement
KevinStillman

Python test for fb group

Dec 7th, 2019
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.88 KB | None | 0 0
  1. #Thank you for trying my little test here. I have never done anything like this before, but I hope
  2. #That i didn't make these too hard or too easy. This was designed to be for beginner level python
  3. #students, not someone who's been learning for a very long time. Again, i've never tried to create
  4. #anything like this, so if I did a terrible job please leave a comment on the facebook post with
  5. #any feedback/questions/concerns!
  6.  
  7. ----------------------------------------------------------------------------------------------------
  8.  
  9.  
  10.  
  11. # Question 1:
  12. # the following code is designed to print out a range
  13. # of numbers (1-20) and print each number followed by "is even" or
  14. # "is odd" depending on if the number is even or odd. Fix the code.
  15. # ** BONUS CHALLENGE** if the number is 3 or 14, print "3/14 is unlucky!"
  16.  
  17. for numbers in range :
  18.    if numbers :
  19.        print
  20.    elif numbers :
  21.        print
  22.    elif numbers :
  23.        print
  24.  
  25.  
  26. #**HINT** USE F STRINGS FOR CLEANER CODE
  27. ####################################################################
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. # Question 2:
  36. # The following code is designed to be a random number guessing game.
  37. # The objective is have the computer generate a random number in a
  38. # range that the user provides, and you have to guess that number.
  39. # If the guess is too high, print "Too high!" or if it's too low,
  40. # print "Too low!" If the guess is correct, print "Winner winner chicken dinner!"
  41. # **BONUS CHALLENGE** add a loop to ask the player if they'd like to play again
  42.  
  43. rng =
  44. answer = randint(0, rng)
  45. guess = int(input(f"Guess a number between 0 and {rng}"))
  46. ##If your guess is too high
  47. while guess
  48.     if guess  answer:
  49.         "Your guess of {guess} was too high, try again!   "
  50.         ##If your guess is too low
  51.     elif guess  answer:
  52.         guess = int(input(f"Your guess of {guess} was too low, try again!   "))
  53. ##If you're correct
  54. if guess = answer:
  55.     input("Great job!")
  56. #Ask to play again
  57.     again "Would you like to play again?"
  58.     #if yes to play again
  59.     if again
  60.  
  61.    #If no to play again
  62.     elif again
  63.         print("Thanks for playing!")
  64.  
  65. #**HINT** how do you have the computer randomly select a number?
  66. ###################################################################
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. # Question 3:
  75. # The following code is designed to mimic a bouncer at a bar. It will ask
  76. # you for your age, and determine whether you're allowed in the bar or if you
  77. # can drink. If you're under 18, you can't go in. If you're 18-20 you can go in
  78. # but no drink alcohol, if you're 21+ you can go in and drink.
  79.  
  80. age = input("How old are you?")
  81. if age:
  82.     # ages 18-21 wear wristbands
  83.     if age
  84.         print("You can enter with a wristband.")
  85.     #21+ drink, normal entry
  86.     elif age
  87.         print("You can enter and drink")
  88.     #<18 too young
  89.  
  90.          print("You cannot come in, young person.")
  91. else:
  92.     print("You didn't enter an age.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement