Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
finished documentation
  • Loading branch information
dianaalvarezz committed Feb 20, 2024
1 parent 1e9abb6 commit 381b028
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@
lowernumber = int(input("Enter the lower bound number: "))
uppernumber = int(input("Enter the upper bound number "))

# Generates the number that is to be guesssed within the specified range
numtoguess = random.randint(lowernumber, uppernumber)
print("\n\tYou have only ",
round(math.log(uppernumber - lowernumber + 1, 2)),
" chances to guess the integer!\n")

# Informs the player of the amount of chances they have
print("\n\tYou have only ", round(math.log(uppernumber - lowernumber + 1, 2)), " chances to guess the integer!\n")

guesses = 0
guesses = 0 #Initialize the number of guesses that will be taken

# Loop that will continue until the user runs out of guesses
while guesses < math.log(uppernumber - lowernumber + 1, 2):
guesses += 1

guess = int(input("Guess a number:- "))
guesses += 1 # Increments the amount of guesses
guess = int(input("Guess a number:- ")) # Promts player the guess

# Checks to see if the guess was correct, too high, or too low
if numtoguess == guess:
print("Congratulations you did it in ",
guesses, " tries")

print("Congratulations you did it in ", guesses, " tries")
break
elif numtoguess > guess:
print("The number you guesses is too small!")
elif numtoguess < guess:
print("The number you guesses is too large!")

# If player runs out of chances than allowed the game will give themm the correct answer
if guesses > math.log(uppernumber - lowernumber + 1, 2):
print("\nThe number was ", numtoguess, ". Nice try!")

Expand Down

0 comments on commit 381b028

Please sign in to comment.