roboratorium

Odgadnij liczbę

Mar 27th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import random
  2. print('Odgadnij liczbę')
  3. print()
  4. sekretnaLiczba = random.randint(1, 100) # ukryta liczba
  5. print('Pomyślałem liczbę pomiędzy 1 and 100.')
  6. for i in range(10): # daj zgadującemu 10 możliwości.
  7. print('Pozostało', (10 - i), 'możliwości. Odgadnij teraz.')
  8. guess = int(input('> ')) # Podaj liczbę.
  9. if guess == sekretnaLiczba:
  10. break # Break out of the for loop if the guess is correct.
  11. if guess < sekretnaLiczba:
  12. print('Liczba jest za mała.')
  13. if guess > sekretnaLiczba:
  14. print('Liczba jest za duża.')
  15. if guess == sekretnaLiczba:
  16. print('Świetnie! Udało się!')
  17. else:
  18. print('Koniec gry. Moja liczba to', sekretnaLiczba)
Advertisement
Add Comment
Please, Sign In to add comment