# “Guess The number” # Problem Statement:- # Generate a random integer from a to b. You and your friend have to guess a number between two numbers a and b. a and b are inputs taken from the user. Your friend is player 1 and plays first. He will have to keep choosing the number and your program must tell whether the number is greater than the actual number or less than the actual number. Log the number of trials it took your friend to arrive at the number. You play the same game and then the person with minimum number of trials wins! Randomly generate a number after taking a and b as input and don’t show that to the user. # # Input: # Enter the value of a # # 4 # # Enter the value of b # # 13 # # Output: # Player1 : # # Please guess the number between 4 and 13 # # 5 # # Wrong guess a greater number again # # 8 # # Wrong guess a smaller number again # # 6 # # Correct you took 3 trials to guess the number # # Player 2: # # Correct you took 7 trials to guess the number # # Player 1 wins! #------------------------- ---------------------------- import random def rand_generator(): return random.randint(a,b) if __name__ == '__main__': a =int(input(' Enter the Lowerlimit:\n ')) b = int(input(' Enter the Upperlimit:\n ')) player1 = input('Enter the name of player1 :\n') player2 = input('Enter the name of player2 :\n') player = player1 answer =rand_generator() print(f'{player}\'s turn-\n') counter =0 while True: print(f'please guess number between {a} and {b}') guess = int(input('Enter your Guess:\n')) counter += 1 if guess == answer: print('Correct') print(f'you took {counter} turns to guess') if player == player2: player2_counter = counter break player = player2 player1_counter = counter print(f'{player}\'s turn-\n') counter =0 answer =rand_generator() elif guessanswer: print(f'Try entering a smaller number') if player1_counter>player2_counter: print(f'\n{player2} has won !!') elif player1_counter g2: print("Player 2 won the match!\n") else: print("Its a Tie!\n") print(f"The number for player 1 was {actual1} and for player 2 was {actual2}")