Write a function called area_circumference_generator that takes a radius of a circle as a function parameter and calculates its circumference and area. Then returns these two results as a tuple and prints the results using tuple unpacking in the function call accorrding to the given format.
[Must use tuple packing & unpacking]
import math
def area_circumference_generator(radius):
"""
:param radius: input parameter
:return: circumference and area as tuple
"""
area = math.pi * radius * radius
cirm = 2 * math.pi * radius
# pack tuple
return area, cirm
# function call
d = area_circumference_generator(1.5)
# unpacking
a, c = d
print("The area is {0} and circumference {1}".format(a, c))
Comments
Leave a comment