From 04a2292b9d53b4a7e286a806a243b64dd4791f0e Mon Sep 17 00:00:00 2001 From: Libbaka Date: Tue, 30 Jan 2024 11:26:27 +0100 Subject: [PATCH 1/3] 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/3] 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/3] 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