l= float(input("Enter length: "))
w= float(input("Enter width: "))
r= float(input("Enter radius: "))
def perimeter():
return (l+w)*2
def circArea():
return (3.14)*(r**2)
def display():
p = perimeter()
print("Perimeter is: ", p)
a = circArea()
print("Area is: ", a)
def main():
display()
main()
I fixed the code, it works now. I realized what i was doing wrong with the returns.
As pointed out in the comments, you return from main
before you compute c
. But even if you didn't, c
is local to main
(as is p
), so it wouldn't be accessible from outside of it. If you want to access the global p
and c
, you have to tell main
that with the global
statement. But that's really a bad way to handle the problem of getting data out of a function; that's what return values are for.