Practice LEGB Rule - 3.2 | Chapter 8: Statements and Scope | ICSE Class 12 Computer Science
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Academics
Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Professional Courses
Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skillsβ€”perfect for learners of all ages.

games

Practice Questions

Test your understanding with targeted questions related to the topic.

Question 1

Easy

What does each letter in LEGB stand for?

πŸ’‘ Hint: You can think of the order Python uses to check variable names.

Question 2

Easy

Provide an example of a Local variable.

πŸ’‘ Hint: Remember, it's defined within a function.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

Question 1

What does 'G' stand for in LEGB?

  • Global
  • General
  • Governing

πŸ’‘ Hint: Think of where the variable is accessible.

Question 2

True or False: The local variables are accessible from outside the function.

  • True
  • False

πŸ’‘ Hint: Consider the scope of variables.

Solve 2 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

Create a function that defines a local variable and attempts to print it from outside the function.

πŸ’‘ Hint: Consider where you are trying to access the variable.

Question 2

Write a code segment that uses the 'nonlocal' keyword to modify a variable in an enclosing scope.

πŸ’‘ Hint: Think about how nested functions interact with variable scope.

Challenge and get performance evaluation