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 86935
In Process

The Archive Base Latest Questions

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

I am a beginner of python and have a question, very confusing for me.

  • 0

I am a beginner of python and have a question, very confusing for me. If I define a function first but within the function I have to use a variable which is defined in another function below, can I do it like this? Or how can I import the return things of another function into a function? for example:

def hello(x,y):     good=hi(iy,ix)     'then do somethings,and use the parameter'good'.'     return something  def hi(iy,ix):     'code'     return good 
  • 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. 2026-05-10T22:19:27+00:00Added an answer on May 10, 2026 at 10:19 pm

    The scope of functions hello and hi are entirely different. They do not have any variables in common.

    Note that the result of calling hi(x,y) is some object. You save that object with the name good in the function hello.

    The variable named good in hello is a different variable, unrelated to the variable named good in the function hi.

    They’re spelled the same, but the exist in different namespaces. To prove this, change the spelling the good variable in one of the two functions, you’ll see that things still work.


    Edit. Follow-up: ‘so what should i do if i want use the result of hi function in hello function?’

    Nothing unusual. Look at hello closely.

    def hello(x,y):     fordf150 = hi(y,x)     'then do somethings,and use the variable 'fordf150'.'     return something  def hi( ix, iy ):     'compute some value, good.'     return good 

    Some script evaluates hello( 2, 3).

    1. Python creates a new namespace for the evaluation of hello.

    2. In hello, x is bound to the object 2. Binding is done position order.

    3. In hello, y is bound to the object 3.

    4. In hello, Python evaluates the first statement, fordf150 = hi( y, x ), y is 3, x is 2.

      a. Python creates a new namespace for the evaluation of hi.

      b. In hi, ix is bound to the object 3. Binding is done position order.

      c. In hi, iy is bound to the object 2.

      d. In hi, something happens and good is bound to some object, say 3.1415926.

      e. In hi, a return is executed; identifying an object as the value for hi. In this case, the object is named by good and is the object 3.1415926.

      f. The hi namespace is discarded. good, ix and iy vanish. The object (3.1415926), however, remains as the value of evaluating hi.

    5. In hello, Python finishes the first statement, fordf150 = hi( y, x ), y is 3, x is 2. The value of hi is 3.1415926.

      a. fordf150 is bound to the object created by evaluating hi, 3.1415926.

    6. In hello, Python moves on to other statements.

    7. At some point something is bound to an object, say, 2.718281828459045.

    8. In hello, a return is executed; identifying an object as the value for hello. In this case, the object is named by something and is the object 2.718281828459045.

    9. The namespace is discarded. fordf150 and something vanish, as do x and y. The object (2.718281828459045), however, remains as the value of evaluating hello.

    Whatever program or script called hello gets the answer.

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

Sidebar

Ask A Question

Stats

  • Questions 86k
  • Answers 86k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can store the timezone offset for the user and… May 11, 2026 at 5:17 pm
  • Editorial Team
    Editorial Team added an answer Generic Tag Names are not possible in ASP.NET, please refer… May 11, 2026 at 5:17 pm
  • Editorial Team
    Editorial Team added an answer Use new Option instead of createElement. var sel = document.getElementById("ddlPersonnel");… May 11, 2026 at 5:17 pm

Related Questions

I have a friend who is finishing up his masters degree in aerospace engineering.
As a complete beginner with no programming experience, I am trying to find beautiful
I am going to spend 30 minutes teaching Perl to an experienced programmer. The
I am currently writting a programe about Conway's Game of life and I am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.