From e1141699dc75d39e77973b642198d9fca8f45f1e Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 12 Sep 2022 18:11:10 +0200 Subject: [PATCH 01/44] =?UTF-8?q?Els=C5=91=20commit=20c=C3=ADme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 012bd27..e20d8bd 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# 5-Python-Projects-For-Beginners \ No newline at end of file +# 5-Python-Projects-For-Beginners + +Első commit tartalma \ No newline at end of file From 2366a2f3d9bfdadd287677b6959c4daac001b9f1 Mon Sep 17 00:00:00 2001 From: Agicka Date: Mon, 12 Sep 2022 19:00:30 +0200 Subject: [PATCH 02/44] =?UTF-8?q?Saj=C3=A1t=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e20d8bd..1f8614c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # 5-Python-Projects-For-Beginners -Első commit tartalma \ No newline at end of file +Első commit tartalma + +Saját commit \ No newline at end of file From 72b60ed9915c092442089dd0c3b049546350b9b5 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 12 Sep 2022 19:23:10 +0200 Subject: [PATCH 03/44] =?UTF-8?q?M=C3=A1sodik=20commit=20c=C3=ADme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e20d8bd..da3e237 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # 5-Python-Projects-For-Beginners -Első commit tartalma \ No newline at end of file +Első commit tartalma, és a második commit tartalma \ No newline at end of file From 2593c9c8a920d97ee5a3150c1743e497eafe9da5 Mon Sep 17 00:00:00 2001 From: LMNikoletta Date: Mon, 12 Sep 2022 19:24:52 +0200 Subject: [PATCH 04/44] =?UTF-8?q?M=C3=A1sodik=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e20d8bd..e0fbb37 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # 5-Python-Projects-For-Beginners -Első commit tartalma \ No newline at end of file +Első commit tartalma +Második commit \ No newline at end of file From 0a487b279804ef0a50a682b39449af5619c0e7dc Mon Sep 17 00:00:00 2001 From: Agicka Date: Mon, 12 Sep 2022 19:31:54 +0200 Subject: [PATCH 05/44] =?UTF-8?q?Saj=C3=A1t=20commit=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f8614c..9de7649 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Első commit tartalma -Saját commit \ No newline at end of file +Saját commit 2 \ No newline at end of file From 55ffef935e4aa993c0a4f228797fefaeff10b3bc Mon Sep 17 00:00:00 2001 From: Albert Date: Sat, 17 Sep 2022 10:26:48 +0200 Subject: [PATCH 06/44] =?UTF-8?q?calculate=20f=C3=BCggv=C3=A9ny=20hozz?= =?UTF-8?q?=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monthly_payment_calculator.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 monthly_payment_calculator.py diff --git a/monthly_payment_calculator.py b/monthly_payment_calculator.py new file mode 100644 index 0000000..ea18446 --- /dev/null +++ b/monthly_payment_calculator.py @@ -0,0 +1,6 @@ +# calculate monthly payment +def calculate(p: int, months: int, rate: float): + return (rate/12) * (1/(1-(1+rate/12)**(-months)))*p + + + From a2ad6a27cbb91043b0de1aa71bab1fda79d6e354 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 12 Sep 2022 20:25:51 +0200 Subject: [PATCH 07/44] =?UTF-8?q?F=C3=BCggv=C3=A9nyes=C3=ADt=C3=A9s=20els?= =?UTF-8?q?=C5=91=20k=C3=B6r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 3249fe4..0dabebd 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -18,18 +18,28 @@ computer_pick = options[random_number] print("Computer picked", computer_pick + ".") - if user_input == "rock" and computer_pick == "scissors": - print("You won!") - user_wins += 1 + def rps_match(user_input_param): - elif user_input == "paper" and computer_pick == "rock": - print("You won!") - user_wins += 1 + if user_input_param == "rock" and computer_pick == "scissors": + print("You won!") + return "user_wins" + + elif user_input_param == "paper" and computer_pick == "rock": + print("You won!") + return "user_wins" - elif user_input == "scissors" and computer_pick == "paper": + elif user_input_param == "scissors" and computer_pick == "paper": + print("You won!") + return "user_wins" + + else: + print("You lost!") + return "computer_wins" + + + if rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 - else: print("You lost!") computer_wins += 1 From 03c0008be35243484cf7de0f1a197fe14dce52db Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:19:47 +0200 Subject: [PATCH 08/44] =?UTF-8?q?Els=C5=91=20teszt=20-=20t=C3=BAl=20er?= =?UTF-8?q?=C5=91sen=20van=20be=C3=A1gyazva=20a=20f=C3=BCggv=C3=A9ny?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test_rock_paper_scissors.py diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py new file mode 100644 index 0000000..eebcad1 --- /dev/null +++ b/test_rock_paper_scissors.py @@ -0,0 +1,8 @@ +import rock_paper_scissors +from rock_paper_scissors import rps_match + + +def test_rps_match(): + computer_pick = "rock" + assert rock_paper_scissors.rps_match("paper") == "You won!" + From ec6e9a80d2be63e5feb8349231fcff3c5f85e7ed Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:21:34 +0200 Subject: [PATCH 09/44] =?UTF-8?q?Els=C5=91=20=C3=A1talak=C3=ADt=C3=A1s=20-?= =?UTF-8?q?=20f=C3=BCggv=C3=A9nyt=20kompaktt=C3=A1=20tessz=C3=BCk,=20de=20?= =?UTF-8?q?m=C3=A9g=20az=20eredeti=20modulban?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 0dabebd..79ccac0 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -13,13 +13,13 @@ if user_input not in options: continue - random_number = random.randint(0, 2) - # rock: 0, paper: 1, scissors: 2 - computer_pick = options[random_number] - print("Computer picked", computer_pick + ".") - def rps_match(user_input_param): + random_number = random.randint(0, 2) + # rock: 0, paper: 1, scissors: 2 + computer_pick = options[random_number] + print("Computer picked", computer_pick + ".") + if user_input_param == "rock" and computer_pick == "scissors": print("You won!") return "user_wins" From 732cfe367b803b917f450267209c5b7e9da174a1 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:24:12 +0200 Subject: [PATCH 10/44] =?UTF-8?q?M=C3=A1sodik=20=C3=A1talak=C3=ADt=C3=A1s?= =?UTF-8?q?=20-=20saj=C3=A1t=20modulba=20helyezz=C3=BCk=20a=20f=C3=BCggv?= =?UTF-8?q?=C3=A9nyt=20(de=20van=20benne=20egy=20hiba)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 26 +------------------------- rps_match.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 rps_match.py diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 79ccac0..f9a461d 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,4 +1,4 @@ -import random +import rps_match user_wins = 0 computer_wins = 0 @@ -13,30 +13,6 @@ if user_input not in options: continue - def rps_match(user_input_param): - - random_number = random.randint(0, 2) - # rock: 0, paper: 1, scissors: 2 - computer_pick = options[random_number] - print("Computer picked", computer_pick + ".") - - if user_input_param == "rock" and computer_pick == "scissors": - print("You won!") - return "user_wins" - - elif user_input_param == "paper" and computer_pick == "rock": - print("You won!") - return "user_wins" - - elif user_input_param == "scissors" and computer_pick == "paper": - print("You won!") - return "user_wins" - - else: - print("You lost!") - return "computer_wins" - - if rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 diff --git a/rps_match.py b/rps_match.py new file mode 100644 index 0000000..9a0e2ba --- /dev/null +++ b/rps_match.py @@ -0,0 +1,25 @@ +import random + + +def rps_match(user_input_param): + + random_number = random.randint(0, 2) + # rock: 0, paper: 1, scissors: 2 + computer_pick = options[random_number] + print("Computer picked", computer_pick + ".") + + if user_input_param == "rock" and computer_pick == "scissors": + print("You won!") + return "user_wins" + + elif user_input_param == "paper" and computer_pick == "rock": + print("You won!") + return "user_wins" + + elif user_input_param == "scissors" and computer_pick == "paper": + print("You won!") + return "user_wins" + + else: + print("You lost!") + return "computer_wins" \ No newline at end of file From 9ba5ce543a23e6d23ece976abbbf3b6b50a3463e Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:28:40 +0200 Subject: [PATCH 11/44] =?UTF-8?q?Harmadik=20=C3=A1talak=C3=ADt=C3=A1s=20-?= =?UTF-8?q?=20Hib=C3=A1k=20jav=C3=ADt=C3=A1sa=20(keress=C3=A9tek=20meg=20?= =?UTF-8?q?=C5=91ket!)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 5 ++--- rps_match.py | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index f9a461d..26d8146 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,10 +1,9 @@ import rps_match +from rps_match import options user_wins = 0 computer_wins = 0 -options = ["rock", "paper", "scissors"] - while True: user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() if user_input == "q": @@ -13,7 +12,7 @@ if user_input not in options: continue - if rps_match(user_input) == "user_wins": + if rps_match.rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 else: diff --git a/rps_match.py b/rps_match.py index 9a0e2ba..3f291f7 100644 --- a/rps_match.py +++ b/rps_match.py @@ -1,25 +1,23 @@ import random +options = ["rock", "paper", "scissors"] + def rps_match(user_input_param): - + random_number = random.randint(0, 2) # rock: 0, paper: 1, scissors: 2 computer_pick = options[random_number] print("Computer picked", computer_pick + ".") if user_input_param == "rock" and computer_pick == "scissors": - print("You won!") return "user_wins" elif user_input_param == "paper" and computer_pick == "rock": - print("You won!") return "user_wins" elif user_input_param == "scissors" and computer_pick == "paper": - print("You won!") return "user_wins" else: - print("You lost!") - return "computer_wins" \ No newline at end of file + return "computer_wins" From fcf5cf8b75dfc6e208ce959078caace753b8d271 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:31:38 +0200 Subject: [PATCH 12/44] =?UTF-8?q?Teszt=20=C3=A1talak=C3=ADt=C3=A1s=20-=20B?= =?UTF-8?q?ukik=20a=20teszt,=20jav=C3=ADtjuk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index eebcad1..f176468 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -1,8 +1,7 @@ -import rock_paper_scissors -from rock_paper_scissors import rps_match +import rps_match def test_rps_match(): computer_pick = "rock" - assert rock_paper_scissors.rps_match("paper") == "You won!" + assert rps_match.rps_match("paper") == "You won!" From acc08245108462a84db2631f51356185ef57091d Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 18:58:13 +0200 Subject: [PATCH 13/44] =?UTF-8?q?Mocking=20hozz=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index f176468..f31a38e 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -1,7 +1,11 @@ import rps_match +import random +from unittest.mock import MagicMock + +random.randint = MagicMock(return_value=0) -def test_rps_match(): - computer_pick = "rock" - assert rps_match.rps_match("paper") == "You won!" +def test_rps_match(): + # computer_pick = "rock" + assert rps_match.rps_match("paper") == "user_wins" From 1971f642db9ef59bcf701c73123e1f9c8a245fce Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 19:44:42 +0200 Subject: [PATCH 14/44] =?UTF-8?q?Hozz=C3=A1adva=208=20m=C3=A1sik=20teszt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index f31a38e..42e38f4 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -3,9 +3,48 @@ from unittest.mock import MagicMock -random.randint = MagicMock(return_value=0) - -def test_rps_match(): - # computer_pick = "rock" +def test_rps_match_paper_rock(): + random.randint = MagicMock(return_value=0) assert rps_match.rps_match("paper") == "user_wins" + + +def test_rps_match_paper_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("paper") == "computer_wins" + + +def test_rps_match_paper_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("paper") == "computer_wins" + + +def test_rps_match_scissors_rock(): + random.randint = MagicMock(return_value=0) + assert rps_match.rps_match("scissors") == "computer_wins" + + +def test_rps_match_scissors_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("scissors") == "user_wins" + + +def test_rps_match_scissors_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("scissors") == "computer_wins" + + +def test_rps_match_rock_rock(): + random.randint = MagicMock(return_value=0) + assert rps_match.rps_match("rock") == "computer_wins" + + +def test_rps_match_rock_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("rock") == "computer_wins" + + +def test_rps_match_rock_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("rock") == "user_wins" + From 62d47f9efb140c3fb72bdee5cb097d5b2019a92e Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 19:51:20 +0200 Subject: [PATCH 15/44] =?UTF-8?q?Hibajav=C3=ADt=C3=A1s:=20d=C3=B6ntetlen?= =?UTF-8?q?=20eset=20kezelve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 6 +++++- rps_match.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 26d8146..f1deef7 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -15,9 +15,13 @@ if rps_match.rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 - else: + + elif rps_match.rps_match(user_input) == "computer_wins": print("You lost!") computer_wins += 1 + else: + print("Nobody wins!") + print("You won", user_wins, "times.") print("The computer won", computer_wins, "times.") diff --git a/rps_match.py b/rps_match.py index 3f291f7..5e3d5cb 100644 --- a/rps_match.py +++ b/rps_match.py @@ -18,6 +18,7 @@ def rps_match(user_input_param): elif user_input_param == "scissors" and computer_pick == "paper": return "user_wins" - + elif user_input_param == computer_pick: + return "nobody wins" else: return "computer_wins" From a2229edc7b294c038ac7d976a4ca23f455ebf8ec Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 20:15:24 +0200 Subject: [PATCH 16/44] =?UTF-8?q?Hibajav=C3=ADt=C3=A1s:=20duplik=C3=A1lt?= =?UTF-8?q?=20h=C3=ADv=C3=A1s=20jav=C3=ADtva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 6 ++++-- test_rock_paper_scissors.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index f1deef7..7d25d87 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -12,11 +12,13 @@ if user_input not in options: continue - if rps_match.rps_match(user_input) == "user_wins": + result = rps_match.rps_match(user_input) + + if result == "user_wins": print("You won!") user_wins += 1 - elif rps_match.rps_match(user_input) == "computer_wins": + elif result == "computer_wins": print("You lost!") computer_wins += 1 else: diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index 42e38f4..ee227c6 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -11,7 +11,7 @@ def test_rps_match_paper_rock(): def test_rps_match_paper_paper(): random.randint = MagicMock(return_value=1) - assert rps_match.rps_match("paper") == "computer_wins" + assert rps_match.rps_match("paper") == "nobody wins" def test_rps_match_paper_scissors(): @@ -31,12 +31,12 @@ def test_rps_match_scissors_paper(): def test_rps_match_scissors_scissors(): random.randint = MagicMock(return_value=2) - assert rps_match.rps_match("scissors") == "computer_wins" + assert rps_match.rps_match("scissors") == "nobody wins" def test_rps_match_rock_rock(): random.randint = MagicMock(return_value=0) - assert rps_match.rps_match("rock") == "computer_wins" + assert rps_match.rps_match("rock") == "nobody wins" def test_rps_match_rock_paper(): From acb6cc395c31256751e874e0d3f5d4184be6f717 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 20:24:59 +0200 Subject: [PATCH 17/44] =?UTF-8?q?F=C3=BCggv=C3=A9nyk=C3=A9nt=20kiemelve=20?= =?UTF-8?q?a=20men=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.py | 32 ++++++++++++++++++++++++++++++++ rock_paper_scissors.py | 31 ++----------------------------- 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 game.py diff --git a/game.py b/game.py new file mode 100644 index 0000000..28390c8 --- /dev/null +++ b/game.py @@ -0,0 +1,32 @@ +import rps_match +from rps_match import options + + +def game(): + user_wins = 0 + computer_wins = 0 + + while True: + user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() + if user_input == "q": + break + + if user_input not in options: + continue + + result = rps_match.rps_match(user_input) + + if result == "user_wins": + print("You won!") + user_wins += 1 + + elif result == "computer_wins": + print("You lost!") + computer_wins += 1 + else: + print("Nobody wins!") + + print("You won", user_wins, "times.") + print("The computer won", computer_wins, "times.") + print("Goodbye!") + diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 7d25d87..e39ba42 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,30 +1,3 @@ -import rps_match -from rps_match import options +import game -user_wins = 0 -computer_wins = 0 - -while True: - user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() - if user_input == "q": - break - - if user_input not in options: - continue - - result = rps_match.rps_match(user_input) - - if result == "user_wins": - print("You won!") - user_wins += 1 - - elif result == "computer_wins": - print("You lost!") - computer_wins += 1 - else: - print("Nobody wins!") - - -print("You won", user_wins, "times.") -print("The computer won", computer_wins, "times.") -print("Goodbye!") +game.game() From 16dae906d6811ef216ecdc311e6dae5bae41c912 Mon Sep 17 00:00:00 2001 From: Agicka Date: Mon, 19 Sep 2022 18:23:14 +0200 Subject: [PATCH 18/44] payment test --- test_monthly_payment_calculator.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test_monthly_payment_calculator.py diff --git a/test_monthly_payment_calculator.py b/test_monthly_payment_calculator.py new file mode 100644 index 0000000..ac20e9e --- /dev/null +++ b/test_monthly_payment_calculator.py @@ -0,0 +1,5 @@ +from monthly_payment_calculator import calculate + + +def test_calculate(): + assert round(calculate(1000000, 48, 0.1)) == 25363 From 37d43ac7091737199435516aef93a96bca717fe7 Mon Sep 17 00:00:00 2001 From: Agicka Date: Mon, 12 Sep 2022 19:00:30 +0200 Subject: [PATCH 19/44] =?UTF-8?q?Saj=C3=A1t=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da3e237..1f8614c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # 5-Python-Projects-For-Beginners -Első commit tartalma, és a második commit tartalma \ No newline at end of file +Első commit tartalma + +Saját commit \ No newline at end of file From bb6f468c22d1378c9dd11c7ddfff818413779e74 Mon Sep 17 00:00:00 2001 From: LMNikoletta Date: Mon, 12 Sep 2022 19:24:52 +0200 Subject: [PATCH 20/44] =?UTF-8?q?M=C3=A1sodik=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f8614c..e0fbb37 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # 5-Python-Projects-For-Beginners Első commit tartalma - -Saját commit \ No newline at end of file +Második commit \ No newline at end of file From 7751d970a36714b4c09b972be84b7e9b60fb359f Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 12 Sep 2022 20:25:51 +0200 Subject: [PATCH 21/44] =?UTF-8?q?F=C3=BCggv=C3=A9nyes=C3=ADt=C3=A9s=20els?= =?UTF-8?q?=C5=91=20k=C3=B6r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 3249fe4..0dabebd 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -18,18 +18,28 @@ computer_pick = options[random_number] print("Computer picked", computer_pick + ".") - if user_input == "rock" and computer_pick == "scissors": - print("You won!") - user_wins += 1 + def rps_match(user_input_param): - elif user_input == "paper" and computer_pick == "rock": - print("You won!") - user_wins += 1 + if user_input_param == "rock" and computer_pick == "scissors": + print("You won!") + return "user_wins" + + elif user_input_param == "paper" and computer_pick == "rock": + print("You won!") + return "user_wins" - elif user_input == "scissors" and computer_pick == "paper": + elif user_input_param == "scissors" and computer_pick == "paper": + print("You won!") + return "user_wins" + + else: + print("You lost!") + return "computer_wins" + + + if rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 - else: print("You lost!") computer_wins += 1 From f30e1bf13312cc7b74b242ad30c3e6f953155887 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:19:47 +0200 Subject: [PATCH 22/44] =?UTF-8?q?Els=C5=91=20teszt=20-=20t=C3=BAl=20er?= =?UTF-8?q?=C5=91sen=20van=20be=C3=A1gyazva=20a=20f=C3=BCggv=C3=A9ny?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test_rock_paper_scissors.py diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py new file mode 100644 index 0000000..eebcad1 --- /dev/null +++ b/test_rock_paper_scissors.py @@ -0,0 +1,8 @@ +import rock_paper_scissors +from rock_paper_scissors import rps_match + + +def test_rps_match(): + computer_pick = "rock" + assert rock_paper_scissors.rps_match("paper") == "You won!" + From bf9fe797d3b61b0a6314fdc4d7f81e88a6d68bc1 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:21:34 +0200 Subject: [PATCH 23/44] =?UTF-8?q?Els=C5=91=20=C3=A1talak=C3=ADt=C3=A1s=20-?= =?UTF-8?q?=20f=C3=BCggv=C3=A9nyt=20kompaktt=C3=A1=20tessz=C3=BCk,=20de=20?= =?UTF-8?q?m=C3=A9g=20az=20eredeti=20modulban?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 0dabebd..79ccac0 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -13,13 +13,13 @@ if user_input not in options: continue - random_number = random.randint(0, 2) - # rock: 0, paper: 1, scissors: 2 - computer_pick = options[random_number] - print("Computer picked", computer_pick + ".") - def rps_match(user_input_param): + random_number = random.randint(0, 2) + # rock: 0, paper: 1, scissors: 2 + computer_pick = options[random_number] + print("Computer picked", computer_pick + ".") + if user_input_param == "rock" and computer_pick == "scissors": print("You won!") return "user_wins" From 0f6f6b6a49c968ada247466966700858cb1b98ee Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:24:12 +0200 Subject: [PATCH 24/44] =?UTF-8?q?M=C3=A1sodik=20=C3=A1talak=C3=ADt=C3=A1s?= =?UTF-8?q?=20-=20saj=C3=A1t=20modulba=20helyezz=C3=BCk=20a=20f=C3=BCggv?= =?UTF-8?q?=C3=A9nyt=20(de=20van=20benne=20egy=20hiba)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 26 +------------------------- rps_match.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 rps_match.py diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 79ccac0..f9a461d 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,4 +1,4 @@ -import random +import rps_match user_wins = 0 computer_wins = 0 @@ -13,30 +13,6 @@ if user_input not in options: continue - def rps_match(user_input_param): - - random_number = random.randint(0, 2) - # rock: 0, paper: 1, scissors: 2 - computer_pick = options[random_number] - print("Computer picked", computer_pick + ".") - - if user_input_param == "rock" and computer_pick == "scissors": - print("You won!") - return "user_wins" - - elif user_input_param == "paper" and computer_pick == "rock": - print("You won!") - return "user_wins" - - elif user_input_param == "scissors" and computer_pick == "paper": - print("You won!") - return "user_wins" - - else: - print("You lost!") - return "computer_wins" - - if rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 diff --git a/rps_match.py b/rps_match.py new file mode 100644 index 0000000..9a0e2ba --- /dev/null +++ b/rps_match.py @@ -0,0 +1,25 @@ +import random + + +def rps_match(user_input_param): + + random_number = random.randint(0, 2) + # rock: 0, paper: 1, scissors: 2 + computer_pick = options[random_number] + print("Computer picked", computer_pick + ".") + + if user_input_param == "rock" and computer_pick == "scissors": + print("You won!") + return "user_wins" + + elif user_input_param == "paper" and computer_pick == "rock": + print("You won!") + return "user_wins" + + elif user_input_param == "scissors" and computer_pick == "paper": + print("You won!") + return "user_wins" + + else: + print("You lost!") + return "computer_wins" \ No newline at end of file From 4b2e7e3c6bc5e7597eab920c6996f72b10f264f2 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:28:40 +0200 Subject: [PATCH 25/44] =?UTF-8?q?Harmadik=20=C3=A1talak=C3=ADt=C3=A1s=20-?= =?UTF-8?q?=20Hib=C3=A1k=20jav=C3=ADt=C3=A1sa=20(keress=C3=A9tek=20meg=20?= =?UTF-8?q?=C5=91ket!)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 5 ++--- rps_match.py | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index f9a461d..26d8146 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,10 +1,9 @@ import rps_match +from rps_match import options user_wins = 0 computer_wins = 0 -options = ["rock", "paper", "scissors"] - while True: user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() if user_input == "q": @@ -13,7 +12,7 @@ if user_input not in options: continue - if rps_match(user_input) == "user_wins": + if rps_match.rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 else: diff --git a/rps_match.py b/rps_match.py index 9a0e2ba..3f291f7 100644 --- a/rps_match.py +++ b/rps_match.py @@ -1,25 +1,23 @@ import random +options = ["rock", "paper", "scissors"] + def rps_match(user_input_param): - + random_number = random.randint(0, 2) # rock: 0, paper: 1, scissors: 2 computer_pick = options[random_number] print("Computer picked", computer_pick + ".") if user_input_param == "rock" and computer_pick == "scissors": - print("You won!") return "user_wins" elif user_input_param == "paper" and computer_pick == "rock": - print("You won!") return "user_wins" elif user_input_param == "scissors" and computer_pick == "paper": - print("You won!") return "user_wins" else: - print("You lost!") - return "computer_wins" \ No newline at end of file + return "computer_wins" From 1e8432606f24b97b018d54eed57cbb2bcfe27777 Mon Sep 17 00:00:00 2001 From: ajonas Date: Tue, 13 Sep 2022 14:31:38 +0200 Subject: [PATCH 26/44] =?UTF-8?q?Teszt=20=C3=A1talak=C3=ADt=C3=A1s=20-=20B?= =?UTF-8?q?ukik=20a=20teszt,=20jav=C3=ADtjuk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index eebcad1..f176468 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -1,8 +1,7 @@ -import rock_paper_scissors -from rock_paper_scissors import rps_match +import rps_match def test_rps_match(): computer_pick = "rock" - assert rock_paper_scissors.rps_match("paper") == "You won!" + assert rps_match.rps_match("paper") == "You won!" From a9f4d75f7f7c8de6b0567bb34d66a2510fdb9a88 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 18:58:13 +0200 Subject: [PATCH 27/44] =?UTF-8?q?Mocking=20hozz=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index f176468..f31a38e 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -1,7 +1,11 @@ import rps_match +import random +from unittest.mock import MagicMock + +random.randint = MagicMock(return_value=0) -def test_rps_match(): - computer_pick = "rock" - assert rps_match.rps_match("paper") == "You won!" +def test_rps_match(): + # computer_pick = "rock" + assert rps_match.rps_match("paper") == "user_wins" From a6fb09a60a2223a02ceda82644a72281adb9bd03 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 19:44:42 +0200 Subject: [PATCH 28/44] =?UTF-8?q?Hozz=C3=A1adva=208=20m=C3=A1sik=20teszt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_rock_paper_scissors.py | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index f31a38e..42e38f4 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -3,9 +3,48 @@ from unittest.mock import MagicMock -random.randint = MagicMock(return_value=0) - -def test_rps_match(): - # computer_pick = "rock" +def test_rps_match_paper_rock(): + random.randint = MagicMock(return_value=0) assert rps_match.rps_match("paper") == "user_wins" + + +def test_rps_match_paper_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("paper") == "computer_wins" + + +def test_rps_match_paper_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("paper") == "computer_wins" + + +def test_rps_match_scissors_rock(): + random.randint = MagicMock(return_value=0) + assert rps_match.rps_match("scissors") == "computer_wins" + + +def test_rps_match_scissors_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("scissors") == "user_wins" + + +def test_rps_match_scissors_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("scissors") == "computer_wins" + + +def test_rps_match_rock_rock(): + random.randint = MagicMock(return_value=0) + assert rps_match.rps_match("rock") == "computer_wins" + + +def test_rps_match_rock_paper(): + random.randint = MagicMock(return_value=1) + assert rps_match.rps_match("rock") == "computer_wins" + + +def test_rps_match_rock_scissors(): + random.randint = MagicMock(return_value=2) + assert rps_match.rps_match("rock") == "user_wins" + From 8a0ac9d6c1bd25ce95296c9d9cd4206ddd9d7edc Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 19:51:20 +0200 Subject: [PATCH 29/44] =?UTF-8?q?Hibajav=C3=ADt=C3=A1s:=20d=C3=B6ntetlen?= =?UTF-8?q?=20eset=20kezelve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 6 +++++- rps_match.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 26d8146..f1deef7 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -15,9 +15,13 @@ if rps_match.rps_match(user_input) == "user_wins": print("You won!") user_wins += 1 - else: + + elif rps_match.rps_match(user_input) == "computer_wins": print("You lost!") computer_wins += 1 + else: + print("Nobody wins!") + print("You won", user_wins, "times.") print("The computer won", computer_wins, "times.") diff --git a/rps_match.py b/rps_match.py index 3f291f7..5e3d5cb 100644 --- a/rps_match.py +++ b/rps_match.py @@ -18,6 +18,7 @@ def rps_match(user_input_param): elif user_input_param == "scissors" and computer_pick == "paper": return "user_wins" - + elif user_input_param == computer_pick: + return "nobody wins" else: return "computer_wins" From ee11bfb43a0ef1f159606d5f38e5e0d91b449348 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 20:15:24 +0200 Subject: [PATCH 30/44] =?UTF-8?q?Hibajav=C3=ADt=C3=A1s:=20duplik=C3=A1lt?= =?UTF-8?q?=20h=C3=ADv=C3=A1s=20jav=C3=ADtva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rock_paper_scissors.py | 6 ++++-- test_rock_paper_scissors.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index f1deef7..7d25d87 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -12,11 +12,13 @@ if user_input not in options: continue - if rps_match.rps_match(user_input) == "user_wins": + result = rps_match.rps_match(user_input) + + if result == "user_wins": print("You won!") user_wins += 1 - elif rps_match.rps_match(user_input) == "computer_wins": + elif result == "computer_wins": print("You lost!") computer_wins += 1 else: diff --git a/test_rock_paper_scissors.py b/test_rock_paper_scissors.py index 42e38f4..ee227c6 100644 --- a/test_rock_paper_scissors.py +++ b/test_rock_paper_scissors.py @@ -11,7 +11,7 @@ def test_rps_match_paper_rock(): def test_rps_match_paper_paper(): random.randint = MagicMock(return_value=1) - assert rps_match.rps_match("paper") == "computer_wins" + assert rps_match.rps_match("paper") == "nobody wins" def test_rps_match_paper_scissors(): @@ -31,12 +31,12 @@ def test_rps_match_scissors_paper(): def test_rps_match_scissors_scissors(): random.randint = MagicMock(return_value=2) - assert rps_match.rps_match("scissors") == "computer_wins" + assert rps_match.rps_match("scissors") == "nobody wins" def test_rps_match_rock_rock(): random.randint = MagicMock(return_value=0) - assert rps_match.rps_match("rock") == "computer_wins" + assert rps_match.rps_match("rock") == "nobody wins" def test_rps_match_rock_paper(): From 57c670060eba9f0c95a7e36811fd1e23f27437be Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 14 Sep 2022 20:24:59 +0200 Subject: [PATCH 31/44] =?UTF-8?q?F=C3=BCggv=C3=A9nyk=C3=A9nt=20kiemelve=20?= =?UTF-8?q?a=20men=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.py | 32 ++++++++++++++++++++++++++++++++ rock_paper_scissors.py | 31 ++----------------------------- 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 game.py diff --git a/game.py b/game.py new file mode 100644 index 0000000..28390c8 --- /dev/null +++ b/game.py @@ -0,0 +1,32 @@ +import rps_match +from rps_match import options + + +def game(): + user_wins = 0 + computer_wins = 0 + + while True: + user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() + if user_input == "q": + break + + if user_input not in options: + continue + + result = rps_match.rps_match(user_input) + + if result == "user_wins": + print("You won!") + user_wins += 1 + + elif result == "computer_wins": + print("You lost!") + computer_wins += 1 + else: + print("Nobody wins!") + + print("You won", user_wins, "times.") + print("The computer won", computer_wins, "times.") + print("Goodbye!") + diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py index 7d25d87..e39ba42 100644 --- a/rock_paper_scissors.py +++ b/rock_paper_scissors.py @@ -1,30 +1,3 @@ -import rps_match -from rps_match import options +import game -user_wins = 0 -computer_wins = 0 - -while True: - user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() - if user_input == "q": - break - - if user_input not in options: - continue - - result = rps_match.rps_match(user_input) - - if result == "user_wins": - print("You won!") - user_wins += 1 - - elif result == "computer_wins": - print("You lost!") - computer_wins += 1 - else: - print("Nobody wins!") - - -print("You won", user_wins, "times.") -print("The computer won", computer_wins, "times.") -print("Goodbye!") +game.game() From 3ffc8d17d59e81a37ac63ae1534692f3b7286633 Mon Sep 17 00:00:00 2001 From: Agicka Date: Mon, 19 Sep 2022 18:39:54 +0200 Subject: [PATCH 32/44] payment test elnevezve --- test_monthly_payment_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_monthly_payment_calculator.py b/test_monthly_payment_calculator.py index ac20e9e..d7372fb 100644 --- a/test_monthly_payment_calculator.py +++ b/test_monthly_payment_calculator.py @@ -1,5 +1,5 @@ from monthly_payment_calculator import calculate -def test_calculate(): +def test_calculate_egymillio_negyev_tizszazalek(): assert round(calculate(1000000, 48, 0.1)) == 25363 From 1ac748c048504c3c5ecf0b5b066ecdcf11578b89 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:08:53 +0200 Subject: [PATCH 33/44] =?UTF-8?q?Kamat=20s=C3=A1zm=C3=ADt=C3=A1s=20els?= =?UTF-8?q?=C5=91=20tesztek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_monthly_payment_calculator.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test_monthly_payment_calculator.py b/test_monthly_payment_calculator.py index d7372fb..01fc760 100644 --- a/test_monthly_payment_calculator.py +++ b/test_monthly_payment_calculator.py @@ -1,5 +1,28 @@ +import pytest + from monthly_payment_calculator import calculate def test_calculate_egymillio_negyev_tizszazalek(): assert round(calculate(1000000, 48, 0.1)) == 25363 + + +def test_calculate_negymillio_tizev_tizszazalek(): + assert round(calculate(4000000, 120, 0.1)) == 52860 + + +def test_calculate_hárommillio_ötev_tizenketszazalek(): + assert round(calculate(3000000, 60, 0.12)) == 66733 + + +def test_calculate_nulla_negyev_tizszazalek(): + assert round(calculate(0, 48, 0.1)) == 0 + + +def test_calculate_egymillio_negyev_nullaszazalek(): + assert round(calculate(1000000, 48, 0)) == 20833 + + +def test_calculate_egymillio_nulla_tizszazalek(): + with pytest.raises(ZeroDivisionError): + assert round(calculate(1000000, 0, 0.1)) == 25363 \ No newline at end of file From 48e6db8f15c6c6a3e3238e8b3c9d07d45456b22f Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:08:53 +0200 Subject: [PATCH 34/44] =?UTF-8?q?Kamat=20sz=C3=A1m=C3=ADt=C3=A1s=20els?= =?UTF-8?q?=C5=91=20tesztek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_monthly_payment_calculator.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test_monthly_payment_calculator.py b/test_monthly_payment_calculator.py index d7372fb..01fc760 100644 --- a/test_monthly_payment_calculator.py +++ b/test_monthly_payment_calculator.py @@ -1,5 +1,28 @@ +import pytest + from monthly_payment_calculator import calculate def test_calculate_egymillio_negyev_tizszazalek(): assert round(calculate(1000000, 48, 0.1)) == 25363 + + +def test_calculate_negymillio_tizev_tizszazalek(): + assert round(calculate(4000000, 120, 0.1)) == 52860 + + +def test_calculate_hárommillio_ötev_tizenketszazalek(): + assert round(calculate(3000000, 60, 0.12)) == 66733 + + +def test_calculate_nulla_negyev_tizszazalek(): + assert round(calculate(0, 48, 0.1)) == 0 + + +def test_calculate_egymillio_negyev_nullaszazalek(): + assert round(calculate(1000000, 48, 0)) == 20833 + + +def test_calculate_egymillio_nulla_tizszazalek(): + with pytest.raises(ZeroDivisionError): + assert round(calculate(1000000, 0, 0.1)) == 25363 \ No newline at end of file From 734a02a20af4f6e4b0a2c24246afbc98b9249198 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:13:54 +0200 Subject: [PATCH 35/44] =?UTF-8?q?test=5Fcalculate=5Fegymillio=5Fnegyev=5Fn?= =?UTF-8?q?ullaszazalek=20jav=C3=ADtva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_monthly_payment_calculator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_monthly_payment_calculator.py b/test_monthly_payment_calculator.py index 01fc760..dc0be98 100644 --- a/test_monthly_payment_calculator.py +++ b/test_monthly_payment_calculator.py @@ -20,7 +20,8 @@ def test_calculate_nulla_negyev_tizszazalek(): def test_calculate_egymillio_negyev_nullaszazalek(): - assert round(calculate(1000000, 48, 0)) == 20833 + with pytest.raises(ZeroDivisionError): + assert round(calculate(1000000, 48, 0)) == 20833 def test_calculate_egymillio_nulla_tizszazalek(): From 54e5befb7228c30fb623a845fd8cffd4a4cb4f7c Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:33:25 +0200 Subject: [PATCH 36/44] =?UTF-8?q?Feladatki=C3=ADr=C3=A1s=20hozz=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 leap_year.py diff --git a/leap_year.py b/leap_year.py new file mode 100644 index 0000000..9ed06ac --- /dev/null +++ b/leap_year.py @@ -0,0 +1,3 @@ +#függvény, aminek egy bemenete van, és egy kimenete, a bemenet az évszám, +#kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. + From 1b65e064938022a92f4c60233257130486a71625 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:37:04 +0200 Subject: [PATCH 37/44] =?UTF-8?q?F=C3=BCggv=C3=A9ny=20csontv=C3=A1z=20mega?= =?UTF-8?q?dva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/leap_year.py b/leap_year.py index 9ed06ac..667b17b 100644 --- a/leap_year.py +++ b/leap_year.py @@ -1,3 +1,6 @@ #függvény, aminek egy bemenete van, és egy kimenete, a bemenet az évszám, #kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. +def leap_year(year: int): + return + From 348a7fe0c13cc5d4449a394091820ac95f89cc1b Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:40:39 +0200 Subject: [PATCH 38/44] =?UTF-8?q?F=C3=BCggv=C3=A9ny=20csontv=C3=A1z=20mega?= =?UTF-8?q?dva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_leap_year.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test_leap_year.py diff --git a/test_leap_year.py b/test_leap_year.py new file mode 100644 index 0000000..1f261ad --- /dev/null +++ b/test_leap_year.py @@ -0,0 +1,2 @@ +def test_leap_year(): + assert False From 065357e51fd44d548f0a761e023e8dbf04a84e55 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:47:48 +0200 Subject: [PATCH 39/44] =?UTF-8?q?Minden=20=C3=A9vre=20False=20=C3=A9rt?= =?UTF-8?q?=C3=A9ket=20kapunk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 2 +- test_leap_year.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/leap_year.py b/leap_year.py index 667b17b..942534e 100644 --- a/leap_year.py +++ b/leap_year.py @@ -2,5 +2,5 @@ #kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. def leap_year(year: int): - return + return False diff --git a/test_leap_year.py b/test_leap_year.py index 1f261ad..ee6bf2d 100644 --- a/test_leap_year.py +++ b/test_leap_year.py @@ -1,2 +1,8 @@ -def test_leap_year(): - assert False +from leap_year import leap_year + + +def test_leap_year_1000(): + assert leap_year(1000) == False + + + From 21a32a091c26a7a37436231bd250d9e84c7f72d8 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 19:55:36 +0200 Subject: [PATCH 40/44] =?UTF-8?q?Minden=20=C3=A9rt=C3=A9kre=20false=20?= =?UTF-8?q?=C3=A9rt=C3=A9kes=20teszt=20kiszedve,=204-el=20oszthat=C3=B3s?= =?UTF-8?q?=C3=A1g=20bevezetve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 5 ++++- test_leap_year.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/leap_year.py b/leap_year.py index 942534e..6b93f28 100644 --- a/leap_year.py +++ b/leap_year.py @@ -2,5 +2,8 @@ #kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. def leap_year(year: int): - return False + if year % 4 == 0: + return True + else: + return False diff --git a/test_leap_year.py b/test_leap_year.py index ee6bf2d..c042f10 100644 --- a/test_leap_year.py +++ b/test_leap_year.py @@ -1,8 +1,13 @@ from leap_year import leap_year -def test_leap_year_1000(): - assert leap_year(1000) == False +def test_leap_year_divisible_by_4(): + assert leap_year(4) == True + assert leap_year(8) == True + assert leap_year(12) == True + assert leap_year(16) == True + + From 817b818d7d29b556a7f3b629b2fcf0cd2ea83425 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 20:04:44 +0200 Subject: [PATCH 41/44] =?UTF-8?q?100-al=20oszthat=C3=B3s=C3=A1g=20bevezetv?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 4 +++- test_leap_year.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/leap_year.py b/leap_year.py index 6b93f28..c010aaa 100644 --- a/leap_year.py +++ b/leap_year.py @@ -2,7 +2,9 @@ #kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. def leap_year(year: int): - if year % 4 == 0: + if year % 100 == 0: + return False + elif year % 4 == 0: return True else: return False diff --git a/test_leap_year.py b/test_leap_year.py index c042f10..f3bffd4 100644 --- a/test_leap_year.py +++ b/test_leap_year.py @@ -8,6 +8,14 @@ def test_leap_year_divisible_by_4(): assert leap_year(16) == True +def test_leap_year_divisible_by_100(): + assert leap_year(100) == False + assert leap_year(200) == False + assert leap_year(500) == False + assert leap_year(1000) == False + assert leap_year(2000) == False + + From bb0cbe3a16022e884c37431140fd6900fe4079e5 Mon Sep 17 00:00:00 2001 From: Albert Date: Mon, 19 Sep 2022 20:13:40 +0200 Subject: [PATCH 42/44] =?UTF-8?q?400-al=20oszthat=C3=B3s=C3=A1g=20bevezetv?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leap_year.py | 4 +++- test_leap_year.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/leap_year.py b/leap_year.py index c010aaa..97cd1d1 100644 --- a/leap_year.py +++ b/leap_year.py @@ -2,7 +2,9 @@ #kimenet pedig igaz vagy hamis, igaz, ha szökőév, hamis, ha nem az. def leap_year(year: int): - if year % 100 == 0: + if year % 400 == 0: + return True + elif year % 100 == 0: return False elif year % 4 == 0: return True diff --git a/test_leap_year.py b/test_leap_year.py index f3bffd4..7312a68 100644 --- a/test_leap_year.py +++ b/test_leap_year.py @@ -13,9 +13,13 @@ def test_leap_year_divisible_by_100(): assert leap_year(200) == False assert leap_year(500) == False assert leap_year(1000) == False - assert leap_year(2000) == False - +def test_leap_year_divisible_by_400(): + assert leap_year(400) == True + assert leap_year(800) == True + assert leap_year(1200) == True + assert leap_year(1600) == True + assert leap_year(2000) == True From b3b7006e0d260d22b338a7180529e070c44c348e Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 21 Sep 2022 18:22:23 +0200 Subject: [PATCH 43/44] =?UTF-8?q?Input-output=20mocking=20hozz=C3=A1adva,?= =?UTF-8?q?=20dummy=20teszt=20hozz=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_game.py | 11 +++++++++++ tud_test_base.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test_game.py create mode 100644 tud_test_base.py diff --git a/test_game.py b/test_game.py new file mode 100644 index 0000000..9a0bc83 --- /dev/null +++ b/test_game.py @@ -0,0 +1,11 @@ +from tud_test_base import set_keyboard_input, get_display_output +import game + + +def test_game(): + + set_keyboard_input(["paper"]) + game.game() + output = get_display_output() + + assert output == ["valami","valami"] diff --git a/tud_test_base.py b/tud_test_base.py new file mode 100644 index 0000000..ad6b3e3 --- /dev/null +++ b/tud_test_base.py @@ -0,0 +1,32 @@ +import builtins + +input_values = [] +print_values = [] + + +def mock_input(s): + print_values.append(s) + return input_values.pop(0) + + +def mock_input_output_start(): + global input_values, print_values + + input_values = [] + print_values = [] + + builtins.input = mock_input + builtins.print = lambda s: print_values.append(s) + + +def get_display_output(): + global print_values + return print_values + + +def set_keyboard_input(mocked_inputs): + global input_values + + mock_input_output_start() + input_values = mocked_inputs + From 8c3576c62c7159c123566dae5aae929b48588975 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 21 Sep 2022 20:32:34 +0200 Subject: [PATCH 44/44] =?UTF-8?q?oszthat=C3=B3s=C3=A1g=20hozz=C3=A1adva,?= =?UTF-8?q?=20input-output=20mockolt=20tesztek=20hozz=C3=A1adva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- divisibility.py | 8 ++++++++ test_divisibility.py | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 divisibility.py create mode 100644 test_divisibility.py diff --git a/divisibility.py b/divisibility.py new file mode 100644 index 0000000..78b7e5e --- /dev/null +++ b/divisibility.py @@ -0,0 +1,8 @@ +# Python Program to Check Number is Divisible by 5 and 11 +def divisibility(): + number = int(input( " Please Enter any Positive Integer : ")) + + if((number % 5 == 0) and (number % 11 == 0)): + print("Given Number {0} is Divisible by 5 and 11".format(number)) + else: + print("Given Number {0} is Not Divisible by 5 and 11".format(number)) \ No newline at end of file diff --git a/test_divisibility.py b/test_divisibility.py new file mode 100644 index 0000000..28fbbfb --- /dev/null +++ b/test_divisibility.py @@ -0,0 +1,26 @@ +from tud_test_base import set_keyboard_input, get_display_output +from divisibility import divisibility + + +def test_divisibility_none(): + set_keyboard_input([3]) + divisibility() + assert get_display_output() == [' Please Enter any Positive Integer : ', "Given Number 3 is Not Divisible by 5 and 11"] + + +def test_divisibility_only_5(): + set_keyboard_input([15]) + divisibility() + assert get_display_output() == [' Please Enter any Positive Integer : ', "Given Number 15 is Not Divisible by 5 and 11"] + + +def test_divisibility_only_11(): + set_keyboard_input([22]) + divisibility() + assert get_display_output() == [' Please Enter any Positive Integer : ', "Given Number 22 is Not Divisible by 5 and 11"] + + +def test_divisibility_both(): + set_keyboard_input([55]) + divisibility() + assert get_display_output() == [' Please Enter any Positive Integer : ', "Given Number 55 is Divisible by 5 and 11"]