간단한 파이썬
-
파이썬으로 직각삼각형의 빗변의 길이 구하는 프로그램 만들기수학시간 파이썬 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}입니다.")
-
파이썬으로 삼각형, 사다리꼴의 넓이 구하는 식 만들기수학시간 파이썬 2024. 3. 6. 21:14
#사용한 기능 더보기 식별자 print() int() * 연산자 # 삼각형 # 밑변의 길이가 b, 높이가 h인 삼각형의 넓이를 s라 할 때, print("삼각형의 넓이") #입력 b = input("밑변의 길이: ") h = input("높이: ") #처리 b = int(b) h = int(h) #출력 s = b*h*(1/2) print(s) #사다리꼴 # 윗변의 길이가 x, 아랫변의 길이가 y, 높이가 hi인 사다리꼴 넓이를 tr이라 할 때, print("사다리꼴의 넓이") #입력 x = input("윗변의 길이: ") y = input("아랫변의 길이: ") hi = input("높이 : ") #처리 tr = (1/2)*(int(x)+int(y))*int(hi) #출력 print(tr)