Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

tcc8m

Question about why these functions return certain values. Thanks in advance. http://pastebin.com/k5wfxp33

  • one year ago
  • one year ago

  • This Question is Closed
  1. eSpeX
    Best Response
    You've already chosen the best response.
    Medals 0

    It is a process similar to the toString() method in Java, when you print an object you are basically getting a printout of its member variables rather than an execution of the object. Take a look at object.__str__(self) in the Python documentation for a more detailed explanation.

    • one year ago
  2. jgoldsmith
    Best Response
    You've already chosen the best response.
    Medals 3

    To expand on what @eSpeX said, look carefully at your definition of zoo(). What does it return? Answer: nothing. A function needs a return statement to return an object. When zoo() is called, another call is made to monkey(), which returns 5 INTO THE FUNCTION zoo(), not as a result of the function. To get the result I assume you are looking for (having zoo() return 5), you need to replace line 5 with "return monkey()". Do you see what would happen if you just wrote "return monkey" with no parens containing arguments?

    • one year ago
  3. jgoldsmith
    Best Response
    You've already chosen the best response.
    Medals 3

    |dw:1353472341103:dw| Does this help clear things up?

    • one year ago
  4. luan.cestari
    Best Response
    You've already chosen the best response.
    Medals 0

    Just as jgoldsmith explained, The problem is that Zoo function doesn't use the keywork 'return' to archive the expected behavior.

    • one year ago
  5. tcc8m
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks everyone. I appreciate the answers. I understand now.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.