シリンダーの表面積と体積を求めるこのプログラムを Python で作成しようとしています。最後に、体積/表面積を計算するかどうかをユーザーに尋ねます。ただし、[はい] と入力しても、何も起こりません。コードの何が問題になっていますか?
次に、math.pi を使用してみましたが、うまくいきませんでした。
コードは長いので、重要な部分まで下にスクロールします。
print("Welcome to the volume and surface area cylinder calculator powered by Python!")
response = input("To calculate the volume type in 'vol', to calculate the surface area, type in 'SA': ")
if response=="vol" or response =="SA":
pass
else:
print("Please enter a correct statement.")
response = input("To calculate the volume type in 'vol', to calculate the surface area, type in 'SA': ")
if response=="vol":
#Below splits
radius, height = [float(part) for part in input("What is the radius and height of the cylinder? (e.g. 32, 15): ").split(',')]
PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
volume = PI*radius*radius*height
decimal_places = int(input("How many decimal places do you want it to?: "))
print("The volume of the cylinder is {0:.{1}f}cm\u00b3".format(volume, decimal_places))
verify = input("Do you want to find out the surface area (type in Yes or No): ")
verify = verify.capitalize
if verify == "Yes":
radius, height = [float(part) for part in input("What is the radius and height of the cylinder? (e.g. 32, 15): ").split(',')]
PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
SA = int(2)*PI*radius*radius+int(2)+radius*radius*height
decimal_places = int(input("How many decimal places do you want it to?: "))
print("The surface area of the cylinder is {0:.{1}f}cm\u00b2".format(SA, decimal_places))
if verify == "No":
pass
if response =="SA":
#Below splits
radius, height = [float(part) for part in input("What is the radius and height of the cylinder? (e.g. 32, 15): ").split(',')]
PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
SA = int(2)*PI*radius*radius+int(2)+radius*radius*height
decimal_places = int(input("How many decimal places do you want it to?: "))
print("The surface area of the cylinder is {0:.{1}f}cm\u00b2".format(SA, decimal_places))
verify = input("Do you want to find out the volume (type in Yes or No): ")
verify = verify.capitalize
if verify == "Yes":
radius, height = [float(part) for part in input("What is the radius and height of the cylinder? (e.g. 32, 15): ").split(',')]
PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
volume = PI*radius*radius*height
decimal_places = int(input("How many decimal places do you want it to?: "))
print("The volume of the cylinder is {0:.{1}f}cm\u00b3".format(volume, decimal_places))
if verify == "No":
pass