Facebook
From Przemysław, 10 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 110
  1. import random
  2. import time
  3.  
  4. failed_try = 0
  5. correct_hits = 0
  6. all_failed_try = 0
  7.  
  8. minimum_number = 1
  9. maximum_number = 1000
  10. my_response = ""
  11. while True:
  12.  
  13.     if failed_try == 0:
  14.         computer_answer = random.randint(minimum_number, maximum_number)
  15.  
  16.     if my_response == "w":
  17.         computer_answer = maximum_number/2
  18.  
  19.     if my_response == "n":
  20.         computer_answer = minimum_number *1.5
  21.  
  22.  
  23.  
  24.     print("Komputer wskaza┼é liczb─Ö", computer_answer)
  25.     my_response = input("""
  26.   Napisz czy jest ona:
  27.  
  28.   p - prawid┼éowa
  29.   w - za wysoka
  30.   n - za niska
  31.  
  32.   wyj┼Ťcie - zako┼äcz program
  33.   """)
  34.     if my_response == "wyj┼Ťcie":
  35.         print("Komputer odgad┼é Twoja liczb─Ö", correct_hits, "razy.\n Potrzebowa┼é do tego", all_failed_try + 1, "pr├│b.")
  36.         input("Aby zako┼äczy─ç prac─Ö programu naci┼Ťnij enter")
  37.         break
  38.  
  39.     if my_response == "p":
  40.         print("Podana liczba jest prawid┼éowa")
  41.         print("Komputer odgad┼é Twoj─ů liczb─Ö za", failed_try + 1, "razem.\nOdlicz─Ö do 3, a Ty wymy┼Ťl now─ů liczb─Ö")
  42.         all_failed_try += failed_try
  43.         failed_try = 0
  44.         correct_hits += 1
  45.         minimum_number = 1
  46.         maximum_number = 1000
  47.         time.sleep(1)
  48.         print("3")
  49.         time.sleep(1)
  50.         print("2")
  51.         time.sleep(1)
  52.         print("1")
  53.         time.sleep(1)
  54.  
  55.     elif my_response == "w":
  56.         print("Podana liczba jest za wysoka")
  57.         maximum_number = computer_answer - 1
  58.         failed_try += 1
  59.         if maximum_number < 1:
  60.             maximum_number = 1
  61.  
  62.         if computer_answer == 1:
  63.             print("Komputer wskaza┼é najni┼╝sz─ů z mo┼╝liwych liczb")
  64.             failed_try -= 1
  65.         print("To jest", failed_try, "pr├│ba")
  66.  
  67.     elif my_response == "n":
  68.         print("Podana liczba jest za niska")
  69.         minimum_number = computer_answer + 1
  70.         failed_try += 1
  71.         if minimum_number > 1000:
  72.             minimum_number = 1000
  73.  
  74.         if computer_answer == 1000:
  75.             print("Komputer wskaza┼é najwy┼╝sz─ů z mo┼╝liwych liczb")
  76.             failed_try -= 1
  77.         print("To jest", failed_try, "pr├│ba")