if문 까지 공부
This commit is contained in:
77
ex) Test.py
77
ex) Test.py
@@ -1,9 +1,9 @@
|
||||
print("goodbye world!")
|
||||
|
||||
# 와우 언빌리버블
|
||||
# 반복문 와우 언빌리버블
|
||||
for i in range(3): print(12)
|
||||
|
||||
# 함수
|
||||
# 함수 (줄바꿈 출력)
|
||||
def hello(name):
|
||||
print("""Hello!
|
||||
Welcome to Codeit""" + name)
|
||||
@@ -29,3 +29,76 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user