

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do nested functions work in Python?
To learn about nested function, refer the following code. In the code, you can see Inner functions can access variables from the enclosing scope, which is the local variable.
def mulFunc(num1): def mul(num2): return num1 * num2 return mul res = mulFunc(15) // The following prints 300 i.e. 20*15 print(res(20))
The above prints the multiplication of num1 and num 2 i.e. 300
- Related Questions & Answers
- How do Python modules work?
- How does nested character class subtraction work in Python?
- Nested functions in C
- How do you create nested dict in Python?
- How to define nested functions in JavaScript?
- How do Python dictionary hash lookups work?
- How do backslashes work in Python Regular Expressions?
- How do cookies work in Python CGI Programming?
- What are JavaScript Nested Functions?
- How exactly do Python functions return/yield objects?
- How do JavaScript closures work?
- How do wind turbines work?
- How do bitcoin ATMs work?
- How do AC locomotives work?
- How do exceptions work in C++
Advertisements