Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6928337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:10:26+00:00 2026-05-27T11:10:26+00:00

I need help understanding a practice exam problem for a CS class in python.

  • 0

I need help understanding a practice exam problem for a CS class in python. The problem deals with the python namespace. Here is the question:

Which of the following are true in Python?

i. Every function has access to the names in the builtin namespace.
ii. Every invocation of a function creates a new namespace nested within the calling function’s namespace.
iii. Invoking function G from function F adds the name G to F’s namespace
iv. The namespace of an imported module is always added to the builtin namespace.

a. i only
b. ii and iii only
c. i and iv only (answer)
d. i, ii and iii only
e. None of the above

Can someone please explain why the second and third cases are false. Or point me to some resources that explain the namespace. Thank-you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:10:27+00:00Added an answer on May 27, 2026 at 11:10 am

    For 2: The new function’s namespace isn’t within the calling function’s namespace: it’s completely separate. An inner function has no access to the variables used in the outer one. The invocation makes a new namespace, but it’s not nested within that of the calling function.

    I didn’t know 3, but it makes sense. The function is invoked and the name isn’t added to the namespace because it’s unnecessary. It’s not added to the function namespace because it’s already in the global namespace (or a class definition) and the function can normally be assumed to have appropriate access to it as needed. And the reference would be useless once the function returned, so there’s no point in adding it to the namespace in the first place.

    Namespace is essentially a matter of who can see what. So a piece of code only knows definitions for things in the namespaces it has access to. A function has access to its own personal namespace (other functions can’t see this) and the global scope/namespace (everything can see this). Think of it like file directories on your computer. You can have two files that are named the same as long as they’re in different directories, and namespaces are handy for most of the same reasons that directories are. Namespaces help force you to organize your code and keep it more modular instead of making hugely intricate dependencies between distant areas of code, and typically saves you from having to keep track of all variable names across potentially millions of lines of code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help understanding some C++ operator overload statements. The class is declared like
I need some help understanding what's happening here. This code is from a models/log.py
I need help understanding this type signature which is from the Thrist package. import
Need some help understanding if I'm on the right track here and exactly what
I need some help understanding scope in Javascript. I posted a similar question earlier
Need help understanding what I am doing with the syntax here, please help! I
I need help understanding the jquery ui autocomplete example found here: http://jqueryui.com/demos/autocomplete/#remote If you
I need help understanding the following. Say I have a display that is 854x480
I need some help understanding this bit of code pre { white-space: pre; white-space:
I'm a SQL noob, and I need a little bit of help understanding the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.