2026fa_cse160/lecture20261027/rectangle2.py

28 lines
561 B
Python

print("\nA Program to calculate the area of a rectangle \n")
# Inputs to the program
length = input("Enter a value for the Length ")
length = float(length)
if length <= 0:
print("Length cannot be negative or zero.")
print("Program terminates here\n")
exit()
width = input("Enter a value for the width ")
width = float(width)
if width <= 0:
print("Width cannot be negative or zero.")
print("Program terminates here\n")
exit()
# Calculation or process the data
area = length * width
# Output results
print(f"The area is {area}")