Untitled Diff

Created Diff never expires
15 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
48 lines
11 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
46 lines
# jaka to liczba nowa edycja
# Jaka to liczba nowa próba


import random
import random


def powitanie():
def powitanie():
print(
print(
"""
"""
Witam w grze 'Jaka to liczba'
Witaj w programie 'Jaka to liczba'
Twoim zadaniem jest odgadnięcie liczby
wylosowanej przez komputer
""")
""")
def yes_or_no(question):
def yes_or_no(question):
response = None
response = None
while response not in("t", "n"):
while response not in ('t', 'n'):
response = input(question).lower()
respone = input(question).lower()
return response
return response

def ask_number(question, low, high):
def ask_number(question, low, high):
response = None
response = None
while response not in range(low, high):
while response not in range(low, high):
response = int(input(question))
response = int(input(question))
return response
return response


def main():
def main():
powitanie()
powitanie()
yes_or_no("Czy jesteś gotowy?")
yes_or_no("Czy jesteś gotowy?")
guess = ask_number("Podaj liczbę: ", 1, 100)
guess = ask_number("Podaj liczbę: ", 1, 100)
tries = 10
tries = 10
number = random.randint(1, 100)
number = random.randint(1, 100)
while guess != number:
while guess != number:
if tries == 0:
if tries <= 0:
break
break
if guess < number:
if guess < number:
print("Za mała...")
print("Za mała...")
elif guess > number:
elif guess > number:
print("Za duża...")
print("Za duża...")
else:
else:
print("Zgadłeś!")
print("Zgadłeś!")
guess = ask_number("Podaj liczbę: ", 1, 100)
guess = ask_number("Podaj liczbę: ", 1, 100)
tries -= 1
tries -= 1

if guess == number:
if guess == number:
print("Zgadłeś. Chodziło mi o liczbę: ", guess)
print("Zgadłeś! Chodziło mi o liczbę: ", guess)
elif tries == 0:
elif tries <= 0:
print("Wyczerpałeś wszystkie próby!")
print("Skończyły ci się próby!")


main()
main()
input("\n\nAby zakończyć program naciśnij enter.")
input("\n\nAby zakończyć naciśnij enter.")