Files
python-study/ex) Test.py
2021-04-26 20:40:14 +09:00

105 lines
2.5 KiB
Python

print("goodbye world!")
# 반복문 와우 언빌리버블
for i in range(3): print(12)
# 함수 (줄바꿈 출력)
def hello(name):
print("""Hello!
Welcome to Codeit""" + name)
# 함수 호출
hello("chris")
hello("zz")
hello("hell")
# 함수
def print_sum(a, b):
print(a + b)
print(a - b)
print(a * b)
print(a / b)
# 함수 호출
print_sum(10, 2)
# 형변환
a = int(10);
b = int(3);
print(a * b);
print(10 * 3);
def is_evenly_divisible(number):
# 코드를 작성하세요
TrueFalse = number % 2 == 0
return TrueFalse
# 테스트
print(is_evenly_divisible(3))
print(is_evenly_divisible(7))
print(is_evenly_divisible(8))
print(is_evenly_divisible(218))
print(is_evenly_divisible(317))
def calculate_change(payment, cost):
# 코드를 작성하세요.
change = payment - cost
fif = change / 50000
ten = (change - (50000 * int(fif))) / 10000
five = (change - (50000 * int(fif)) - (10000 * int(ten))) / 5000
one = (change - (50000 * int(fif)) - (10000 * int(ten)) - (5000 * int(five))) / 1000
print("50000원 지폐: {}".format(int(fif)))
print("10000원 지폐: {}".format(int(ten)))
print("5000원 지폐: {}".format(int(five)))
print("1000원 지폐: {}".format(int(one)))
# 테스트
calculate_change(100000, 33000)
print()
calculate_change(500000, 378000)
def calculate_change(payment, cost):
# 코드를 작성하세요.
change = payment - cost
fif = change / 50000
ten = change % 50000 / 10000
five = change % 50000 % 10000 / 5000
one = change % 50000 % 10000 % 5000 / 1000
print("50000원 지폐: {}".format(int(fif)))
print("10000원 지폐: {}".format(int(ten)))
print("5000원 지폐: {}".format(int(five)))
print("1000원 지폐: {}".format(int(one)))
# 테스트
calculate_change(100000, 33000)
print()
calculate_change(500000, 378000)
def calculate_change(payment, cost):
change = payment - cost # 거스름돈 총액
fifty_count = change // 50000 # 50,000원 지폐
ten_count = (change % 50000) // 10000 # 10,000원 지폐
five_count = (change % 10000) // 5000 # 5,000원 지폐
one_count = (change % 5000) // 1000 # 1,000원 지폐
# 답 출력
print("50000원 지폐: {}".format(fifty_count))
print("10000원 지폐: {}".format(ten_count))
print("5000원 지폐: {}".format(five_count))
print("1000원 지폐: {}".format(one_count))
# 테스트
calculate_change(100000, 33000)
print()
calculate_change(500000, 378000)