SHARE
TWEET

Untitled

a guest Feb 20th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randint
  2. no_of_guesses = 0
  3. correct_guesses = 0
  4. while True  :
  5.     correct_num = randint(1,9)
  6.     guessed_option = input("Guess a number between 1 and 9 : ")
  7.    
  8.     if guessed_option == "exit" :
  9.         print("Total no of guesses = %d"%(no_of_guesses))
  10.         print("Total no of correct guesses =%d"%(correct_guesses))
  11.         break
  12.     else :
  13.         if int(guessed_option) == correct_num :
  14.             print ("exactly right")
  15.             no_of_guesses +=1
  16.             correct_guesses +=1
  17.         elif int(guessed_option ) < correct_num :
  18.             print("too less")
  19.             no_of_guesses +=1
  20.         elif int(guessed_option) > correct_num :
  21.             print("too much")
  22.             no_of_guesses +=1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top