Write a program that reads the first capital letter ("T", "C", "O", "D" or "I") of the polyhedron the size of a side and which prints the volume of the corresponding polyhedron. If the letter read is not one of the 5 letters, your program prints "Unknown Polyhedron".
This prints almost every input value as the value of "else statement" but it should print the volume of the polyhedron based on the letter that user inputs and also the measure of the side.
import math
p = str(input())
a = float(input())
T = (math.sqrt(2) / 12) * (a ** 3)
C = a ** 3
O = (math.sqrt(2) / 3) * (a ** 3)
D = (15 + 7 * math.sqrt(5)) / 4 * (a ** 3)
I = 5 * (3 + math.sqrt(5)) / 12 * (a ** 3)
if p == (math.sqrt(2) / 12) * (a ** 3) :
print (T)
elif p == a ** 3 :
print(C)
elif p == (math.sqrt(2) / 3) * (a ** 3) :
print(O)
elif p == (15 + 7 * math.sqrt(5)) / 4 * (a ** 3) :
print(D)
elif p == 5 * (3 + math.sqrt(5)) / 12 * (a ** 3) :
print(I)
else :
print('Polyèdre non connu')
Aucun commentaire:
Enregistrer un commentaire