私はPythonで面積計算機に取り組んでいますが、すべて問題ないようです...円の周囲を計算するまで...
誰かが私を正しい方向に向けることができますか?
import math
from math import pi
menu = """
Pick a shape(1-3):
1) Square (area)
2) Rectangle (area)
3) Circle (area)
4) Square (perimeter)
5) Rectangle (perimeter)
6) Circle (perimeter)
7) Quit
"""
shape = int(input(menu))
while shape != 7:
if shape == 1:
length = float(input("Length: "))
print( "Area of square = ", length ** 2 )
elif shape == 2:
length = float(input("Length: "))
width = float(input("Width: "))
print( "Area of rectangle = ", length * width )
elif shape == 3:
area = float(input("Radius: "))
circumference = float(input("radius: "))
print( "Area of Circle = ", pi*radius**2 )
elif shape == 4:
length = float(input("Length: "))
print( "Perimeter of square = ", length *4 )
elif shape == 5:
length = float(input("Length: "))
width = float(input("Width: "))
print( "Perimeter of rectangle = ", (length*2) + (width*2))
elif shape == 6:
circumference = float(input("radius: "))
print( "Perimeter of Circle = ", 2*pi*radius)
shape = int(input(menu))