Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Functions within Functions | Functions within Functions
Python Functions: From Zero to Hero
Sectionย 5. Chapterย 1
single

single

bookFunctions within Functions

Swipe to show menu

Inside the function, we can not only write loops, declare variables, use if-else statements but also call other functions. Let's look at an example.

1234567
def function_1(): # Outer function print('I am an outer function') def function_2(): # Inner function print('I am an inner function ') function_2() function_1()
copy
Task

Swipe to start coding

You have to implement two functions:

  • outer_function - this is an outer function that displays text like this: The perimeter of this square is equal to:
  • inner_function - this is an inner function, which calculates the perimeter of a square whose side is 7.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 5. Chapterย 1
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt