2
#import square root function from math
from math import sqrt

print("Cuboid Calculator")

print()

#Input
#Gather width, length and height with user input
w = float(input("Enter the width (cm): "))
l = float(input("Enter the length (cm): "))
h = float(input("Enter the height (cm): "))

print()

#Process
#Calculate the area, volume and diagonal of cuboid
area = 2*(l*w + l*h + w*h)
volume = l*w*h
diagonal = sqrt(l**2 + w**2 + h**2)

print()

#Output
print("Area of the cuboid is", round(area, 4), "square cm")
print("Space diagonal of the cuboid is", round(diagonal, 3), "cm")
print("Volume of the cuboid is", round(volume, 2), "cubic cm")

print()

print("**Cuboid dimensions**")
#print the width, length and height rounded off to 1 decimal and with tabs in between
print("width =", round(w,1), "cm" + '\t' + "length = ", round(l,1), "cm" + '\t' + "height =", round(h,1), "cm")

I tried making the variables floats but that also failed and I have no idea why only my second tab is being displayed.

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96

0 Answers0