Skip to content
Programs · Program 10-3

Q.Program 10-3: Write a program to compute the area and circumference of a circle using a function.

Telangana TsbieTextbookSubjective· 3mImportance★★★★★est
20% · 6/30 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Return (area, circumference) as one tuple from the function and unpack it at the call site — for radius 5 the results are 78.5 and 31.400000000000002.

The idea. A Python function can return only one object — but that object can be a tuple, which is how we return multiple values cleanly. The caller mirrors the shape with tuple unpacking: (area, circumference) = circle(radius). This example computes both circle measures (with the textbook's approximation 3.14 for pi) in a single call.

Program 10-3:

def circle(r):
    area = 3.14 * r * r
    circumference = 2 * 3.14 * r
    return (area, circumference)   # a function can return a tuple

radius = float(input("Enter the radius of the circle: "))
(area, circumference) = circle(radius)
print("Area of the circle:", area)
print("Circumference of the circle:", circumference)

Sample run (radius = 5):

Enter the radius of the circle: 5
Area of the circle: 78.5
Circumference of the circle: 31.400000000000002

Working, in plain arithmetic:

area          = 3.14 x 5 x 5  = 78.5
circumference = 2 x 3.14 x 5  = 31.4
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.