Last active
January 9, 2021 11:33
-
-
Save rotaliator/3bed5d142e0807b322f744bbdd442fe2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randrange | |
import sys | |
import time | |
def beep(): | |
sys.stdout.write('\r\a') | |
def guess(min, max): | |
secret = randrange(min, max + 1) | |
print(f"Podaj liczbę od {min} do {max}") | |
l = None | |
while l != secret: | |
try: | |
beep() | |
l = int(input("Liczba: ")) | |
except KeyboardInterrupt: | |
print("Pa pa :)") | |
exit() | |
if l < secret: | |
print(f"{l} to za mało. Spróbuj większą liczbę :)") | |
if l > secret: | |
print(f"{l} to za dużo. Spróbuj mniejszą liczbę :)") | |
beep() | |
print("Brawo! Zgadłeś! :D 🎆👍") | |
if __name__ == "__main__": | |
try: | |
min = int(sys.argv[1]) | |
max = int(sys.argv[2]) | |
except (ValueError, IndexError): | |
min = 1 | |
max = 100 | |
print("Podaj wartość minimalną i maksymalną jako paramerty") | |
print("Uruchamiam dla zakresu 1-100") | |
if min < max: | |
guess(min, max) | |
else: | |
print("Najpierw mniejsza liczba, potem większa :)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
from random import randrange | |
import sys | |
import time | |
def beep(): | |
sys.stdout.write('\r\a') | |
def guess(min, max): | |
secret = randrange(min, max + 1) | |
print("Podaj liczbę od {min} do {max}".format(min=min, max=max)) | |
l = None | |
while l != secret: | |
try: | |
beep() | |
l = int(input("Liczba: ")) | |
except KeyboardInterrupt: | |
print("Pa pa :)") | |
exit() | |
if l < secret: | |
print("{l} to za mało. Spróbuj większą liczbę :)".format(l=l)) | |
if l > secret: | |
print("{l} to za dużo. Spróbuj mniejszą liczbę :)".format(l=l)) | |
beep() | |
print("Brawo! Zgadłeś! :D 🎆👍") | |
if __name__ == "__main__": | |
try: | |
min = int(sys.argv[1]) | |
max = int(sys.argv[2]) | |
except (ValueError, IndexError): | |
min = 1 | |
max = 100 | |
print("Podaj wartość minimalną i maksymalną jako paramerty") | |
print("Uruchamiam dla zakresu 1-100") | |
if min < max: | |
guess(min, max) | |
else: | |
print("Najpierw mniejsza liczba, potem większa :)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment