Skip to content

Instantly share code, notes, and snippets.

@sec-fortress
Created April 10, 2024 22:11
Show Gist options
  • Save sec-fortress/1a058c5638dd50f7ff8f9d6c75ca8d4c to your computer and use it in GitHub Desktop.
Save sec-fortress/1a058c5638dd50f7ff8f9d6c75ca8d4c to your computer and use it in GitHub Desktop.
A codex Area Calculator Checkpoint Project
print("Shapes:")
print("1. Square\n2. Rectangle\n3. Triangle\n4. Circle")
while True:
shape = int(input("What shape do you want? "))
if shape in [1, 2, 3, 4]:
if shape == 1:
side = float(input("Enter side: "))
print(f"Area of a Square is equal to {side * side}")
elif shape == 2:
length = float(input("Enter length: "))
width = float(input("Enter width: "))
print(f"Area of a Rectangle is equal to {length * width}")
elif shape == 3:
height = float(input("Enter height: "))
base = float(input("Enter base: "))
print(f"Area of a Triangle is equal to {(height * base)/2}")
elif shape == 4:
pi = 3.14
radius = float(input("Enter radius: "))
print(f"Area of a Circle is equal to {pi * radius**2}")
break
else:
print("Invalid input! Please enter a valid option.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment