Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
malfred koryor
2,093 PointsCan someone please help me figure out how does calling another function into a function function work?
def area_circle(radius): return 3.14*(radius**2)
def inside(hight): area_circle(3) if hight > 2: print("awesome") inside(3) area_circle(3)
Having just a hard time getting the idea in my head, can someone please explain it in details. have no clue what I'm doing in this code by the way. Thanks!
2 Answers
Ezra Siton
12,644 PointsThis is the correct code:
def area_circle(radius):
return 3.14*(radius**2)
def inside(height):
print(area_circle(3))
#returns: 28.26
if height > 2: print("awesome")
return
# Now you can call area_circle function
print(area_circle(3))
#returns: 28.26
print(inside(3))
#returns: awesome
print(inside(area_circle(3)))
#returns: awesome
Ezra Siton
12,644 Pointsdef area_circle(radius):
return 3.14*(radius**2)
# Now you can call area_circle function
print(area_circle(3))
In this example first "area_circle" returns the valus (3.14*3*2) = 28.26...Than print(28.26)
malfred koryor
2,093 PointsThanks!!