Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Akash-Ansari/ea2501632cec2fd269da74f9d678382a to your computer and use it in GitHub Desktop.
Save Akash-Ansari/ea2501632cec2fd269da74f9d678382a to your computer and use it in GitHub Desktop.
# Calculating Area for Rectangle and Circle
import math
def get_area(shape):
shape = shape.lower()
if shape == "rectangle":
rectangle_area()
elif shape == "circle":
circle_area()
else:
print("Please enter rectangle or circle")
def rectangle_area():
length = float(input("Enter the length: "))
width = float(input("Enter the width: "))
area = length * width
print("The area of the rectangle is ", area)
def circle_area():
radius = float(input("Enter the radius: "))
area = math.pi * (math.pow(radius, 2))
print("The area of the circle is {:.2f}".format(area))
def main():
shape_type = input("Get area for what shape: ")
get_area(shape_type)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment