-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputValidation.py
More file actions
39 lines (31 loc) · 1.19 KB
/
InputValidation.py
File metadata and controls
39 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# ***************************************************************
# Name : Input Validation
# Author: Than Tong
# Created : * Course: CIS189
# Version: 1.0
# OS: Windows 11
# IDE: Python
# Copyright : This is my own original work
# based onspecifications issued by our instructor
# Description :
# Input: ADD HERE XXX
# Ouput: ADD HERE XXX
# Academic Honesty: I attest that this is my original work.
# I have not used unauthorized source code, either modified or
# unmodified. I have not given other fellow student(s) access
# to my program.
def calculate_square_feet():
try:
length = float(input("Enter the length of the house in feet: "))
width = float(input("Enter the width of the house in feet: "))
if length < 0 or width < 0:
raise ValueError("Length and width cannot be negative.")
square_feet = length * width
except ValueError as e:
print(f"Error: {e}. Please enter valid positive numbers.")
else:
print(f"The square footage of the house is {square_feet:.2f} square feet.")
finally:
print("Thank you!")
if __name__ == "__main__":
calculate_square_feet()