Answer to Question #279646 in Python for Munif

Question #279646

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]

1
Expert's answer
2021-12-15T02:09:34-0500
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS