import math
radius=float(input("enter a radius value: "))
def area_circumference_generator(radius):
circumference1=(2*math.pi*radius)
area1=(math.pi)*(radius**2)
tuple1=(area1,circumference1)
print(tuple1)
print("Area of the circle is:",area1) print("Circumference of the circle is:",circumference1) area_circumference_generator(radius)
CodePudding user response:
You can't reference a local variable from outside a function this way. You should first return its value.
import math
radius=float(input("enter a radius value: "))
def area_circumference_generator(radius):
circumference1=(2*math.pi*radius)
area1 = (math.pi)*(radius**2)
tuple1 = (area1,circumference1)
return tuple1
print(area_circumference_generator(radius))
CodePudding user response:
You can run it this way:
import math
def area_circumference_generator(radius):
circumference1 = (2*math.pi*radius)
area1 = (math.pi)*(radius**2)
tuple1 = (area1, circumference1)
return tuple1
if __name__ == '__main__':
radius = float(input("Enter the radius of the circle: "))
print(area_circumference_generator(radius))