피타고라스의 정리
-
파이썬으로 직각삼각형의 빗변의 길이 구하는 프로그램 만들기수학시간 파이썬 2024. 3. 6. 21:26
#사용한 기능 더보기 식별자 print() int() * 연산자 #피타고라스의 정리 직각삼각형의 빗변의 길이가 c, 다른 두 변의 길이가 각각 a, b일 때 피타고라스의 정리에 따라 빗변의 길이를 구하는 프로그램 빗변의 길이의 c, 다른 두 변의 길이를 a, b라 할 때, !c = \sqrt[]{}(a^{2}+b^{2})* 더보기 정답 #입력 a = input("밑변: ") b = input("높이: ") a = float(a) b = float(b) #처리 c = ((a**2)+(b**2))**(1/2) #출력 print (f"밑변의 길이 : {a}") print (f"높이의 길이 : {b}") print (f"빗변의 길이는 {c}입니다.")