0

Im writing a program tha outputs the area and perimeter of a shape after they entered the name of the shape and its dimensions. It worked until my pentagon code but after that for the area, it just returns none as the area:

import math

def perimeter_pentagon(lenght): #function for perimiter of pentagon 
    pentPerimeter=5*length
    return(pentPerimeter)

def area_pentagon(length): #function for area of a pentagon
    PentagonArea=(1/4*math.sqrt(5*(5+2*math.sqrt(5)))*length*length)

shape=input("Enter your shape ") #asks the user for their shape
(skipping the other if and elif statments)
else:
    length=float(input("Enter the length "))
    PentagonArea=area_pentagon(length)
    PentagonPerimeter=perimeter_pentagon(length)
    print("The area of your pentagon is: ", PentagonArea)
    print("The perimeter of your pentagon is: ", PentagonPerimeter)
MyNameIsCaleb
  • 4,409
  • 1
  • 13
  • 31
ShadowRunner
  • 33
  • 1
  • 8
  • 2
    Possible duplicate of [Python Function Returning None](https://stackoverflow.com/questions/21471876/python-function-returning-none) or maybe more canonical: [Function returns None without return statement](https://stackoverflow.com/questions/7053652/function-returns-none-without-return-statement) – pault Sep 25 '19 at 18:33

1 Answers1

1

You need to return your value from your function.

def area_pentagon(length): #function for area of a pentagon
    PentagonArea=(1/4*math.sqrt(5*(5+2*math.sqrt(5)))*length*length)
    return PentagonArea

or just shorten it right to the return statement:

def area_pentagon(length): #function for area of a pentagon
    return (1/4*math.sqrt(5*(5+2*math.sqrt(5)))*length*length)
MyNameIsCaleb
  • 4,409
  • 1
  • 13
  • 31