Practice Chennai Mathematical Institute, Madras (33.1.3) - Global scope, nested functions
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Chennai Mathematical Institute, Madras

Practice - Chennai Mathematical Institute, Madras

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

Define a global variable and print it in a function.

💡 Hint: Make sure to declare the variable outside any function.

Question 2 Easy

Create a function that uses a nested function to calculate and return the sum of two numbers. Declare one of the numbers as a global variable.

💡 Hint: Remember to call the nested function from within the outer function.

1 more question available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What is a global variable?

A variable used only inside a function
A variable that can be accessed anywhere in the program
A variable that is local to a single function

💡 Hint: Consider where the variable is declared.

Question 2

True or False: Nested functions can access variables from their enclosing function.

True
False

💡 Hint: Reflect on how variables visibility works in Python.

Get performance evaluation

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a program that simulates a simple banking system with global variables for account balance and nested functions for deposit and withdraw operations.

💡 Hint: Think of how to modify and return the nested function outputs.

Challenge 2 Hard

Implement a calculator in Python using global variables for operands and nested functions for each arithmetic operation.

💡 Hint: Ensure to pass global operands into nested functions.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.