From 04a2292b9d53b4a7e286a806a243b64dd4791f0e Mon Sep 17 00:00:00 2001 From: Libbaka Date: Tue, 30 Jan 2024 11:26:27 +0100 Subject: [PATCH 1/7] hadaci hra cislo --- .../hadaci hra cislo/.idea/.gitignore | 3 +++ .../.idea/hadaci hra cislo.iml | 8 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .../hadaci hra cislo/.idea/misc.xml | 4 ++++ .../hadaci hra cislo/.idea/modules.xml | 8 +++++++ .../hadaci hra cislo/.idea/vcs.xml | 6 +++++ .../hadaci hra cislo/Hadaci hra cislo.py | 24 +++++++++++++++++++ 7 files changed, 59 insertions(+) create mode 100644 1] guessing game/hadaci hra cislo/.idea/.gitignore create mode 100644 1] guessing game/hadaci hra cislo/.idea/hadaci hra cislo.iml create mode 100644 1] guessing game/hadaci hra cislo/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 1] guessing game/hadaci hra cislo/.idea/misc.xml create mode 100644 1] guessing game/hadaci hra cislo/.idea/modules.xml create mode 100644 1] guessing game/hadaci hra cislo/.idea/vcs.xml create mode 100644 1] guessing game/hadaci hra cislo/Hadaci hra cislo.py diff --git a/1] guessing game/hadaci hra cislo/.idea/.gitignore b/1] guessing game/hadaci hra cislo/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/1] guessing game/hadaci hra cislo/.idea/hadaci hra cislo.iml b/1] guessing game/hadaci hra cislo/.idea/hadaci hra cislo.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/hadaci hra cislo.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/1] guessing game/hadaci hra cislo/.idea/inspectionProfiles/profiles_settings.xml b/1] guessing game/hadaci hra cislo/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/1] guessing game/hadaci hra cislo/.idea/misc.xml b/1] guessing game/hadaci hra cislo/.idea/misc.xml new file mode 100644 index 0000000..a0f56f8 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/1] guessing game/hadaci hra cislo/.idea/modules.xml b/1] guessing game/hadaci hra cislo/.idea/modules.xml new file mode 100644 index 0000000..683d844 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/1] guessing game/hadaci hra cislo/.idea/vcs.xml b/1] guessing game/hadaci hra cislo/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/1] guessing game/hadaci hra cislo/Hadaci hra cislo.py b/1] guessing game/hadaci hra cislo/Hadaci hra cislo.py new file mode 100644 index 0000000..6666461 --- /dev/null +++ b/1] guessing game/hadaci hra cislo/Hadaci hra cislo.py @@ -0,0 +1,24 @@ +import random + +def hra_hadani_cisel(): + vylosovane_cislo = random.randint(1, 100) + + while True: + tip = input("Guess the number: ") + + if not tip.isdigit(): + print("It's not a number!") + continue + + tip = int(tip) + + if tip < vylosovane_cislo: + print("Too small!") + elif tip > vylosovane_cislo: + print("Too big!") + else: + print("You win!") + break + +if __name__ == "__main__": + hra_hadani_cisel() From 8beafc5d9842f6fd9290061d8622e1937ba5ec46 Mon Sep 17 00:00:00 2001 From: Libbaka Date: Tue, 30 Jan 2024 11:48:27 +0100 Subject: [PATCH 2/7] loto --- 2] loto/hra lotto.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 2] loto/hra lotto.py diff --git a/2] loto/hra lotto.py b/2] loto/hra lotto.py new file mode 100644 index 0000000..5b9c93c --- /dev/null +++ b/2] loto/hra lotto.py @@ -0,0 +1,41 @@ +import random +def zadej_cislo(): + while True: + cislo = input("Your number (1-49): ") + + if not cislo.isdigit(): + print("It's not a number!") + continue + + cislo = int(cislo) + + if cislo < 1 or cislo > 49: + print("Number must be in range 1-49.") + continue + + return cislo + +def hra_lotto(): + vybrane_cisla = [] + for _ in range(6): + cislo = zadej_cislo() + while cislo in vybrane_cisla: + print("This number is already chosen. Try another.") + cislo = zadej_cislo() + vybrane_cisla.append(cislo) + + vybrane_cisla.sort() + print(f"Vybraná čísla: {vybrane_cisla}") + + vylosovana_cisla = random.sample(range(1, 50), 6) + vylosovana_cisla.sort() + print(f"Vylosovaná čísla: {vylosovana_cisla}") + + shodna_cisla = set(vybrane_cisla) & set(vylosovana_cisla) + + print(f"Počet shodných čísel: {len(shodna_cisla)}") + print(f"Shodná čísla: {shodna_cisla}") + + +if __name__ == "__main__": + hra_lotto() \ No newline at end of file From 752a9929313c2e47dd43c41aad104e9955bcc49c Mon Sep 17 00:00:00 2001 From: Libbaka Date: Thu, 1 Feb 2024 21:27:12 +0100 Subject: [PATCH 3/7] guessing game 2 --- 3] guessing game 2/.idea/.gitignore | 8 +++++ .../.idea/3] guessing game 2.iml | 8 +++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ 3] guessing game 2/.idea/misc.xml | 4 +++ 3] guessing game 2/.idea/modules.xml | 8 +++++ 3] guessing game 2/.idea/vcs.xml | 6 ++++ 3] guessing game 2/Guess game 2.py | 29 +++++++++++++++++++ 7 files changed, 69 insertions(+) create mode 100644 3] guessing game 2/.idea/.gitignore create mode 100644 3] guessing game 2/.idea/3] guessing game 2.iml create mode 100644 3] guessing game 2/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 3] guessing game 2/.idea/misc.xml create mode 100644 3] guessing game 2/.idea/modules.xml create mode 100644 3] guessing game 2/.idea/vcs.xml create mode 100644 3] guessing game 2/Guess game 2.py diff --git a/3] guessing game 2/.idea/.gitignore b/3] guessing game 2/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/3] guessing game 2/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/3] guessing game 2/.idea/3] guessing game 2.iml b/3] guessing game 2/.idea/3] guessing game 2.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/3] guessing game 2/.idea/3] guessing game 2.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/3] guessing game 2/.idea/inspectionProfiles/profiles_settings.xml b/3] guessing game 2/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/3] guessing game 2/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/3] guessing game 2/.idea/misc.xml b/3] guessing game 2/.idea/misc.xml new file mode 100644 index 0000000..dc9ea49 --- /dev/null +++ b/3] guessing game 2/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/3] guessing game 2/.idea/modules.xml b/3] guessing game 2/.idea/modules.xml new file mode 100644 index 0000000..934c3b2 --- /dev/null +++ b/3] guessing game 2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/3] guessing game 2/.idea/vcs.xml b/3] guessing game 2/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/3] guessing game 2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/3] guessing game 2/Guess game 2.py b/3] guessing game 2/Guess game 2.py new file mode 100644 index 0000000..e014c70 --- /dev/null +++ b/3] guessing game 2/Guess game 2.py @@ -0,0 +1,29 @@ +import random + +def guessing_number2(): + print("Myslim na cislo mezi 1 a 1000.") + nejnizsi = 1 + nejvyssi = 1000 + pokusy = 10 + + for i in range(pokusy): + hadane_cislo = random.randint(nejnizsi, nejvyssi) + print(f"Pocitac hada: {hadane_cislo}") + + odpoved = input("Cislo je prilis male (m), prilis velke (v) nebo vyhravate (s): ") + + if odpoved == "m": + nejnizsi = hadane_cislo + 1 + elif odpoved == "v": + nejvyssi = hadane_cislo - 1 + elif odpoved == "s": + print("Pocitac vyhral!") + break + else: + print("Neplatna odpoved. Zadejte 'm' pro prilis male, 'v' pro prilis velke nebo 's' pro vyhravate.") + + else: + print("Maximalni pocet pokusu. Vyhravate!") + +if __name__ == "__main__": + guessing_number2() \ No newline at end of file From 473eb6ce48a28768e3c99ead1f1fdbf1960ddf6f Mon Sep 17 00:00:00 2001 From: Libbaka <156096050+Libbaka@users.noreply.github.com> Date: Thu, 1 Feb 2024 21:36:49 +0100 Subject: [PATCH 4/7] Add files via upload --- 3] guessing game 2/Guess game 2.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 3] guessing game 2/Guess game 2.py diff --git a/3] guessing game 2/Guess game 2.py b/3] guessing game 2/Guess game 2.py new file mode 100644 index 0000000..e014c70 --- /dev/null +++ b/3] guessing game 2/Guess game 2.py @@ -0,0 +1,29 @@ +import random + +def guessing_number2(): + print("Myslim na cislo mezi 1 a 1000.") + nejnizsi = 1 + nejvyssi = 1000 + pokusy = 10 + + for i in range(pokusy): + hadane_cislo = random.randint(nejnizsi, nejvyssi) + print(f"Pocitac hada: {hadane_cislo}") + + odpoved = input("Cislo je prilis male (m), prilis velke (v) nebo vyhravate (s): ") + + if odpoved == "m": + nejnizsi = hadane_cislo + 1 + elif odpoved == "v": + nejvyssi = hadane_cislo - 1 + elif odpoved == "s": + print("Pocitac vyhral!") + break + else: + print("Neplatna odpoved. Zadejte 'm' pro prilis male, 'v' pro prilis velke nebo 's' pro vyhravate.") + + else: + print("Maximalni pocet pokusu. Vyhravate!") + +if __name__ == "__main__": + guessing_number2() \ No newline at end of file From 47ba2b6e23030fea131571cc159a5cd3bc483420 Mon Sep 17 00:00:00 2001 From: Libbaka <156096050+Libbaka@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:05:53 +0100 Subject: [PATCH 5/7] Add files via upload --- 4] guessing game 3/skuska.py | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 4] guessing game 3/skuska.py diff --git a/4] guessing game 3/skuska.py b/4] guessing game 3/skuska.py new file mode 100644 index 0000000..f138c08 --- /dev/null +++ b/4] guessing game 3/skuska.py @@ -0,0 +1,85 @@ +from flask import Flask, request + +app = Flask(__name__) + +HTML_START = """ + + + + + Hadejte cislo + + +

Myslete na cislo mezi 1 a 1000

+

Nerikejte vase cislo ;)

+
+ + + +
+ + +""" + + +HTML = """ + + + + + Hadejte cislo + + +

Je vase cislo {guess}?

+
+ + + + + + + +
+ + +""" + + +HTML_WIN = """ + + + + Hadejte cislo + + +

Huraaa! Uhodl jsem! Vase cislo je {guess}

+ + + +""" + + +@app.route("/", methods=["GET", "POST"]) +def hadejte_cislo(): + if request.method == "GET": + return HTML_START.format(0, 1001) + else: + min_number = int(request.form.get("min")) + max_number = int(request.form.get("max")) + user_answer = request.form.get("user_answer") + guess = int(request.form.get("guess", 500)) + + if user_answer == "prilis velke": + max_number = guess + elif user_answer == "prilis male": + min_number = guess + elif user_answer == "vyhral/a jste": + return HTML_WIN.format(guess=guess) + + guess = (max_number - min_number) // 2 + min_number + + return HTML.format(guess=guess, min=min_number, max=max_number) + + +if __name__ == '__main__': + app.run() \ No newline at end of file From 960d1f26013ee18903c87603c44f2dddceb8a3de Mon Sep 17 00:00:00 2001 From: Libbaka <156096050+Libbaka@users.noreply.github.com> Date: Sat, 3 Feb 2024 10:36:32 +0100 Subject: [PATCH 6/7] Add files via upload --- 1] guessing game/Hadaci hra cislo.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 1] guessing game/Hadaci hra cislo.py diff --git a/1] guessing game/Hadaci hra cislo.py b/1] guessing game/Hadaci hra cislo.py new file mode 100644 index 0000000..7c924cb --- /dev/null +++ b/1] guessing game/Hadaci hra cislo.py @@ -0,0 +1,21 @@ +import random +def guess_the_number(): + secret_number = random.randint(1, 100) + + while True: + try: + user_guess = int(input("Hádej číslo: ")) + + if user_guess < secret_number: + print("Příliš malé!") + elif user_guess > secret_number: + print("Příliš velké!") + else: + print("Vyhráváte!") + break + + except ValueError: + print("Není to číslo!") + +if __name__ == "__main__": + guess_the_number() From cec9b918e120a92cf4cdf08095bdda7805bceaa7 Mon Sep 17 00:00:00 2001 From: Libbaka <156096050+Libbaka@users.noreply.github.com> Date: Sat, 3 Feb 2024 11:11:54 +0100 Subject: [PATCH 7/7] Add files via upload --- 2] loto/lottohra.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 2] loto/lottohra.py diff --git a/2] loto/lottohra.py b/2] loto/lottohra.py new file mode 100644 index 0000000..329488a --- /dev/null +++ b/2] loto/lottohra.py @@ -0,0 +1,25 @@ +import random +def lotto_game(): + user_numbers = set() + + while len(user_numbers) < 6: + try: + user_input = int(input("Zadejte číslo (1-49): ")) + if 1 <= user_input <= 49 and user_input not in user_numbers: + user_numbers.add(user_input) + else: + print("Neplatný vstup, zadejte platné číslo v rozsahu 1-49.") + except ValueError: + print("Neplatný vstup, zadejte platné číslo v rozsahu 1-49.") + + sorted_user_numbers = sorted(user_numbers) + print("Vaše vybraná čísla:", sorted_user_numbers) + + drawn_numbers = set(random.sample(range(1, 50), 6)) + print("Vylosovaná čísla:", drawn_numbers) + + matched_numbers = set(sorted_user_numbers).intersection(drawn_numbers) + print("Počet shodných čísel:", len(matched_numbers)) + +if __name__ == "__main__": + lotto_game()