Practice Scope In Programming (33.7.1) - 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

Scope in Programming

Practice - Scope in Programming

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

Define a global variable and explain how it can be accessed.

💡 Hint: Think about where you declare the variable.

Question 2 Easy

What is local scope?

💡 Hint: Consider where the variable is defined.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What is a global variable?

A variable defined inside a function
A variable accessible throughout the module
A variable that exists only within a loop

💡 Hint: Remember where the variable is declared.

Question 2

True or False: Local variables can be accessed outside the function they are defined in.

True
False

💡 Hint: Consider the definition of local scope.

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a program that utilizes both global and local variables. Show how changing a global variable affects the output of a function that relies on a local variable of the same name.

💡 Hint: Remember to print both values before and after modifying the global variable.

Challenge 2 Hard

Write a Python program that demonstrates the use of a nested function to calculate a total salary based on hourly wages and hours worked. Explain the memory implications of retaining the outer function's variables.

💡 Hint: Make sure to calculate and print the salary within the nested function.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.