Created
February 4, 2017 07:41
-
-
Save Akash-Ansari/ea2501632cec2fd269da74f9d678382a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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