# New Rectangle and Cuboid finder code

unknown
python
a year ago
2.1 kB
4
Indexable
Never
```print("WARNING: Only numbers should be entered into input. Negative numbers and zero are not viable inputs for the height or length, if entered, program will have you renter the height or length with a new number. Negative numbers also are not viable inputs for the width, zero may be used as input for width.  If strings are entered, program will have you renter the height, length, or width as a number. If height, length, or width entered as blank, contains a space or symbols, or entered as a combination of numbers and letters the program will still output an error.")
print(" ")
print("NOTICE: If only trying to calculate for a rectangle, use 0 for width.")
print(" ")
while True:
height = input("Insert Height: ")
if height.isalpha():
next
elif int(height) > 0:
print("✓")
break
print("✗")
while True:
length = input("Insert Length: ")
if length.isalpha():
next
elif int(length) > 0:
print("✓")
break
print("✗")
while True:
width = input("Insert Width: ")
if width.isalpha():
next
elif int(width) > 0:
print("✓")
break
elif int(width) == 0:
print("✓")
break
print("✗")
rectarea = int(height) * int(length)
cubevol = int(height) * int(length) * int(width)
rectperi = (int(height) * 2) + (int(length) * 2)
cubeperi = (int(height) * 4) + (int(length) * 4) + (int(width) * 4)
cubesa = (2 * int(length) * int(width)) + (2 * int(length) * int(height)) + (2 * int(height) * int(width))
print(" ")
print("The height is", height + ".")
print("The length is", length + ".")
print("The width is", width + ".")
print("The rectangle's area is", str(rectarea) + ".")
if int(width) != 0:
print("The cuboid's volume is", str(cubevol) + ".")
print("The rectangle's perimeter is", str(rectperi) + ".")
if int(width) != 0:
print("The cuboid's perimeter is", str(cubeperi) + ".")
if int(width) != 0:
print("The cuboid's surface area is", str(cubesa) + ".")```