Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e114169
Első commit címe
Sep 12, 2022
2366a2f
Saját commit
Agicka Sep 12, 2022
72b60ed
Második commit címe
Sep 12, 2022
2593c9c
Második commit
LMNikoletta Sep 12, 2022
92128c7
Merge pull request #3 from Albert-Jonas/nikolett_branch
Albert-Jonas Sep 12, 2022
0a487b2
Saját commit 2
Agicka Sep 12, 2022
aa62280
Merge branch 'main' into Agi_branch
Albert-Jonas Sep 12, 2022
55ffef9
calculate függvény hozzáadva
Sep 17, 2022
a2ad6a2
Függvényesítés első kör
Sep 12, 2022
03c0008
Első teszt - túl erősen van beágyazva a függvény
Sep 13, 2022
ec6e9a8
Első átalakítás - függvényt kompakttá tesszük, de még az eredeti modu…
Sep 13, 2022
732cfe3
Második átalakítás - saját modulba helyezzük a függvényt (de van benn…
Sep 13, 2022
9ba5ce5
Harmadik átalakítás - Hibák javítása (keressétek meg őket!)
Sep 13, 2022
fcf5cf8
Teszt átalakítás - Bukik a teszt, javítjuk
Sep 13, 2022
acc0824
Mocking hozzáadva
Sep 14, 2022
1971f64
Hozzáadva 8 másik teszt
Sep 14, 2022
62d47f9
Hibajavítás: döntetlen eset kezelve
Sep 14, 2022
a2229ed
Hibajavítás: duplikált hívás javítva
Sep 14, 2022
acb6cc3
Függvényként kiemelve a menü
Sep 14, 2022
fa71f11
Merge branch 'Albert_branche' of https://github.com/Albert-Jonas/5-Py…
Agicka Sep 19, 2022
16dae90
payment test
Agicka Sep 19, 2022
37d43ac
Saját commit
Agicka Sep 12, 2022
bb6f468
Második commit
LMNikoletta Sep 12, 2022
7751d97
Függvényesítés első kör
Sep 12, 2022
f30e1bf
Első teszt - túl erősen van beágyazva a függvény
Sep 13, 2022
bf9fe79
Első átalakítás - függvényt kompakttá tesszük, de még az eredeti modu…
Sep 13, 2022
0f6f6b6
Második átalakítás - saját modulba helyezzük a függvényt (de van benn…
Sep 13, 2022
4b2e7e3
Harmadik átalakítás - Hibák javítása (keressétek meg őket!)
Sep 13, 2022
1e84326
Teszt átalakítás - Bukik a teszt, javítjuk
Sep 13, 2022
a9f4d75
Mocking hozzáadva
Sep 14, 2022
a6fb09a
Hozzáadva 8 másik teszt
Sep 14, 2022
8a0ac9d
Hibajavítás: döntetlen eset kezelve
Sep 14, 2022
ee11bfb
Hibajavítás: duplikált hívás javítva
Sep 14, 2022
57c6700
Függvényként kiemelve a menü
Sep 14, 2022
3ffc8d1
payment test elnevezve
Agicka Sep 19, 2022
ead8d95
Merge pull request #9 from Albert-Jonas/Agi_branch
Albert-Jonas Sep 19, 2022
1ac748c
Kamat sázmítás első tesztek
Sep 19, 2022
48e6db8
Kamat számítás első tesztek
Sep 19, 2022
e29cb1b
Merge remote-tracking branch 'origin/Albert_branche' into Albert_branche
Sep 19, 2022
734a02a
test_calculate_egymillio_negyev_nullaszazalek javítva
Sep 19, 2022
54e5bef
Feladatkiírás hozzáadva
Sep 19, 2022
1b65e06
Függvény csontváz megadva
Sep 19, 2022
348a7fe
Függvény csontváz megadva
Sep 19, 2022
065357e
Minden évre False értéket kapunk
Sep 19, 2022
21a32a0
Minden értékre false értékes teszt kiszedve, 4-el oszthatóság bevezetve
Sep 19, 2022
817b818
100-al oszthatóság bevezetve
Sep 19, 2022
bb0cbe3
400-al oszthatóság bevezetve
Sep 19, 2022
b3b7006
Input-output mocking hozzáadva, dummy teszt hozzáadva
Sep 21, 2022
8c3576c
oszthatóság hozzáadva, input-output mockolt tesztek hozzáadva
Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# 5-Python-Projects-For-Beginners
# 5-Python-Projects-For-Beginners

Első commit tartalma
Második commit
8 changes: 8 additions & 0 deletions divisibility.py
Original file line number Diff line number Diff line change
@@ -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))
32 changes: 32 additions & 0 deletions game.py
Original file line number Diff line number Diff line change
@@ -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!")

13 changes: 13 additions & 0 deletions leap_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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):
if year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False

6 changes: 6 additions & 0 deletions monthly_payment_calculator.py
Original file line number Diff line number Diff line change
@@ -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



40 changes: 2 additions & 38 deletions rock_paper_scissors.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
import random
import game

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":
break

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 + ".")

if user_input == "rock" and computer_pick == "scissors":
print("You won!")
user_wins += 1

elif user_input == "paper" and computer_pick == "rock":
print("You won!")
user_wins += 1

elif user_input == "scissors" and computer_pick == "paper":
print("You won!")
user_wins += 1

else:
print("You lost!")
computer_wins += 1

print("You won", user_wins, "times.")
print("The computer won", computer_wins, "times.")
print("Goodbye!")
game.game()
24 changes: 24 additions & 0 deletions rps_match.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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":
return "user_wins"

elif user_input_param == "paper" and computer_pick == "rock":
return "user_wins"

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"
26 changes: 26 additions & 0 deletions test_divisibility.py
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 11 additions & 0 deletions test_game.py
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 25 additions & 0 deletions test_leap_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from leap_year import leap_year


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


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


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


29 changes: 29 additions & 0 deletions test_monthly_payment_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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():
with pytest.raises(ZeroDivisionError):
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
50 changes: 50 additions & 0 deletions test_rock_paper_scissors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import rps_match
import random

from unittest.mock import MagicMock


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") == "nobody 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") == "nobody wins"


def test_rps_match_rock_rock():
random.randint = MagicMock(return_value=0)
assert rps_match.rps_match("rock") == "nobody 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"

32 changes: 32 additions & 0 deletions tud_test_base.py
Original file line number Diff line number Diff line change
@@ -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