반응형
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
if __name__ == '__main__':
meal_cost = float(input())
tip_percent = int(input())
tax_percent = int(input())
solve(meal_cost, tip_percent, tax_percent)
우리가 def함수를 만들어내야한다.
tip은 (meal_cost / 100) * tip_percent
tax는 (meal_cost / 100) * tax_percent로 구한다고 한다.
그렇게해서 total_cost를 구하는 문제이다.
근데 total_cost는 반올림을 하라고한다.
우린 벌써 답을 다 구했다.
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
tip = (meal_cost / 100) * tip_percent
tax = (meal_cost / 100) * tax_percent
total_cost = meal_cost + tip + tax
print(round(total_cost))
if __name__ == '__main__':
meal_cost = float(input())
tip_percent = int(input())
tax_percent = int(input())
solve(meal_cost, tip_percent, tax_percent)
'Hacker rank Challenge > python' 카테고리의 다른 글
30 DAYS Challenge 4일차 (0) | 2021.01.21 |
---|---|
30 Days Challenge 3일차 (0) | 2021.01.19 |
30 Days Challenge 1일차 (0) | 2021.01.17 |
30 Days Challenge 0일차 (0) | 2021.01.16 |
HackerRank Challenge 3일차 (0) | 2021.01.15 |