Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def main():
- print("Wpisz liczbę: ")
- result = int(input())
- tries = 0
- finish = False
- smallerNumber = 1
- greaterNumber = 100
- while not finish:
- compResult = int((smallerNumber+greaterNumber)/2)
- print("Komputer zgaduje... Liczba: " + str(compResult))
- tries += 1
- if compResult == result:
- print("Komputer zgadł liczbę " + str(compResult) + " w " + str(tries) + " próbach")
- finish = True
- elif compResult > result:
- greaterNumber = compResult-1
- print("Nacisnij dowolny klawisz, w celu kolejnej proby komputer. Bedzie to proba numer " + str(tries+1))
- # input()
- elif compResult < result:
- smallerNumber = compResult+1
- print("Nacisnij dowolny klawisz, w celu kolejnej proby komputer. Bedzie to proba numer " + str(tries+1))
- # input()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement