수학시간
-
파이썬으로 구의 겉넓이, 부피 구하는 식 만들기수학시간 파이썬 2024. 3. 6. 21:23
#사용한 기능 더보기 식별자 print() int() * 연산자 # 구의 부피와 겉넓이를 구하는 프로그램 (단, 원주율은 3.14로 계산한다.) 구의 반지름을 r이라고 할 때 부피 : ! \frac{4}{3}\pi r^{3} * 겉넓이 : ! 4\pi r^{2} * 더보기 정답 pi = 3.14 r = input("구의 반지름을 입력해주세요: ") print("구의 부피는 {}입니다.".format((4/3)*pi*float(r)**3)) print("구의 겉넓이는 {}입니다.".format(4*pi*float(r)**2)) 다른 정답 #입력 rad = input("구의 반지름을 입력해주세요: ") rad = float(rad) #처리 부피 = (4/3)*pi*(rad**3) 겉넓이 = 4*pi*(rad..