관리 메뉴

솜씨좋은장씨

[BaekJoon] 4714번 : Lunacy (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 4714번 : Lunacy (Python)

솜씨좋은장씨 2022. 8. 24. 12:56
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Lunacy 입니다.

 

4714번: Lunacy

After several months struggling with a diet, Jack has become obsessed with the idea of weighing less. In an odd way, he finds it very comforting to think that, if he had simply had the luck to be born on a different planet, his weight could be considerably

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def lunacy(weight):
    lunacy_weight = round(weight * 0.167, 2)
    
    return lunacy_weight


def convert_weight_to_answer_format(weight):
    return "%.2f"%weight



def convert_str_to_answer_format(weight, lunacy_weight):
    return f"Objects weighing {weight} on Earth will weigh {lunacy_weight} on the moon."


if __name__ == "__main__":
    while True:
        weight = float(input())
        
        if weight == -1.0:
            break
            
        lunacy_weight = lunacy(weight=weight)
        weight = convert_weight_to_answer_format(weight=weight)
        lunacy_weight = convert_weight_to_answer_format(weight=lunacy_weight)        
        
        print(convert_str_to_answer_format(weight=weight, lunacy_weight=lunacy_weight))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments