This project is a fun game that generates a random number in a certain specified range and the user must guess the number after receiving hints. Every time a user's guess is wrong they are prompted with more hints to make it easier at the cost of reducing the score. www

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter2: Elements Of High-quality Programs
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
6
11
12
13
8
9 points = [10, 7, 4, 1]
scores=0
15
16
17
18
19
20
21
22
23
29
38
31
32
33
34
35
36
37
38
39
40
41
This project is a fun game that generates a random number in a certain
specified range and the user must guess the number after receiving hints.
Every time a user's guess is wrong they are prompted with more hints to
make it easier at the cost of reducing the score.
from random import randint
44
45
24
25
26
27 def guessNumber():
28
def generateNumber():
51
52
53
54
55
56
57
return randint (10, 20)
def generateHint (secretNumber, userGuess, rounds):
if rounds == 0:
hint = "The number is between 10 and 20"
elif rounds == 1:
hint= "The number is a even number" if secretNumber % 2 == 0 else "The number is an odd number"
else:
hint = "The number is lesser" if userGuess > secretNumber else "The number is greater"
return hint
secretNumber = generateNumber()
for eachRound in range(0, 4):
user Input = int(input("Enter your guess: "))
if userInput == secretNumber:
print("Hurray! You have guessed the secret number!")
return points[eachRound]
elif user Input != secret Number and eachRound != 3:
print("Wrong guess! Try again")
42
43 def countScores (point):
print (generateHint (secretNumber, user Input, eachRound))
elif user Input != secretNumber and eachRound == 3:
print("Sorry wrong guess.... Better luck next time.")
return 0
score= scores + point
return score
46
47
48 if _name__ == "__main__":
49
while 1:
print("=========
print("\t\t\t\t\t\t\t\t ||")
print("\t\tGuess The Number \t\t II")
print("\t\t\t\t\t\t\t\t ||")
print("================
scores = countScores (guessNumber())
print (f"Your score is {scores} points")
Transcribed Image Text:6 11 12 13 8 9 points = [10, 7, 4, 1] scores=0 15 16 17 18 19 20 21 22 23 29 38 31 32 33 34 35 36 37 38 39 40 41 This project is a fun game that generates a random number in a certain specified range and the user must guess the number after receiving hints. Every time a user's guess is wrong they are prompted with more hints to make it easier at the cost of reducing the score. from random import randint 44 45 24 25 26 27 def guessNumber(): 28 def generateNumber(): 51 52 53 54 55 56 57 return randint (10, 20) def generateHint (secretNumber, userGuess, rounds): if rounds == 0: hint = "The number is between 10 and 20" elif rounds == 1: hint= "The number is a even number" if secretNumber % 2 == 0 else "The number is an odd number" else: hint = "The number is lesser" if userGuess > secretNumber else "The number is greater" return hint secretNumber = generateNumber() for eachRound in range(0, 4): user Input = int(input("Enter your guess: ")) if userInput == secretNumber: print("Hurray! You have guessed the secret number!") return points[eachRound] elif user Input != secret Number and eachRound != 3: print("Wrong guess! Try again") 42 43 def countScores (point): print (generateHint (secretNumber, user Input, eachRound)) elif user Input != secretNumber and eachRound == 3: print("Sorry wrong guess.... Better luck next time.") return 0 score= scores + point return score 46 47 48 if _name__ == "__main__": 49 while 1: print("========= print("\t\t\t\t\t\t\t\t ||") print("\t\tGuess The Number \t\t II") print("\t\t\t\t\t\t\t\t ||") print("================ scores = countScores (guessNumber()) print (f"Your score is {scores} points")
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Rendering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage