Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions RectangleArea.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
length_input = int(input("What is the length you chose?\n"))
width_input = int(input("What is the width you chose?\n"))
def get_valid_input(prompt):
while True:
try:
value = int(input(prompt))
if 1 <= value <= 10:
return value
else:
print("Invalid input. Please enter a number between 1 and 10.")
except ValueError:
print("Invalid input. Please enter a number.")


def draw_rectangle(length_input, width_input):
for i in range(length_input):
for j in range(width_input):
print("=" , end="")
print("=", end="")
print()

area = length_input * width_input

print("==========================")
def main():
length_input = get_valid_input("What is the length you chose?\n")
width_input = get_valid_input("What is the width you chose?\n")

area = length_input * width_input

print("==========================")

print("Here is your length: ", length_input)
print("Here is your width: ", width_input)
input("Press Enter to see area...")

print("Here is your length: ", length_input)
print("Here is your width: ", width_input)
input("Press Enter to see area...")
print("=========================")
print("Your area equals: ", area)
print("=========================")
draw_rectangle(length_input, width_input)
print("==========================")

print("=========================")
print("Your area equals: ", area)
print("=========================")
draw_rectangle(length_input, width_input)
print("==========================")

if __name__ == "__main__":
main()