Lecture code 10/27/2026
This commit is contained in:
parent
9f2a91d67d
commit
aad4e226c5
7 changed files with 152 additions and 0 deletions
28
lecture20261027/rectangle2.py
Normal file
28
lecture20261027/rectangle2.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
|
||||
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}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue