SHARE
TWEET

Untitled

a guest Jun 17th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. def main():
  5.     print("Wpisz liczbę: ")
  6.     result = int(input())
  7.     tries = 0
  8.     finish = False
  9.     smallerNumber = 1
  10.     greaterNumber = 100
  11.  
  12.     while not finish:
  13.         compResult = random.randint(smallerNumber, greaterNumber)
  14.         print("Komputer zgaduje... Liczba: " + str(compResult))
  15.         tries += 1
  16.         if compResult == result:
  17.             print("Komputer zgadł liczbę " + str(compResult) + " w " + str(tries) + " próbach")
  18.             finish = True
  19.         elif compResult > result:
  20.             greaterNumber = compResult-1
  21.             print("Nacisnij dowolny klawisz, w celu kolejnej proby komputer. Bedzie to proba numer " + str(tries+1))
  22.             input()
  23.         elif compResult < result:
  24.             smallerNumber = compResult+1
  25.             print("Nacisnij dowolny klawisz, w celu kolejnej proby komputer. Bedzie to proba numer " + str(tries+1))
  26.             input()
  27.  
  28.  
  29. if __name__ == "__main__":
  30.     main()
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