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

bramas

What does it mean when code is said to be "outside a function?"

  • 9 months ago
  • 9 months ago

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

    The pro's will probably answer better, but the only time I have seen that error is when my "return" line is not inside of a function.

    • 9 months ago
  2. rsmith6559
    Best Response
    You've already chosen the best response.
    Medals 0

    In Python, there's a very good chance that it comes from an indentation error.

    • 9 months ago
  3. bramas
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you neec() but what does 'outside' or 'inside' of a function mean? rsmith6559 - thanks I'll look out for the indentation error.

    • 9 months ago
  4. Neec0
    Best Response
    You've already chosen the best response.
    Medals 0

    @bramas a function is a type of object in Python, similar to a method. If you haven't used functions yet, I am curious how you are using a "return" statement. Below is a very basic function. http://pastebin.com/gvZHdJH7

    • 9 months ago
  5. Neec0
    Best Response
    You've already chosen the best response.
    Medals 0

    I just realized I may have went over board in the wrong direction with that last response. Inside the function means that it is indented correctly inside your function.

    • 9 months ago
  6. e.mccormick
    Best Response
    You've already chosen the best response.
    Medals 0

    If you define a function, you put things inside it. Sort of like... Lets say your overall program is a house. Inside a house you have many rooms and each room serves a purpose. The rooms are not the house and the house is not the rooms, but they are related. Each room has many things inside it that are for that room's use. A person can go from room to room and carry things with them, doing things in different rooms. The program is the house. The functions are the rooms. Anything in any room is inside that room. Anything in a second room is OUTSIDE the first room. They are both in the program, but they have separate inside the room and outside the room or inside the function and outside the function areas. The execution of the program would be the person coming into the house and doing things in different rooms. In the bedroom function there is the loop "sleep while tired." In the kitchen there is the for food in meal: cook food, which returns the results to the dinning room where there is for food in meal: eat food. The loop for sleeping is inside the bedroom, but outside the kitchen and dining room. Even though the kitchen and dining room are related, things inside one are not inside the other.

    • 9 months ago
  7. bramas
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks a lot! I get it now. It really comes down to proper indentation of expressions under their relevant functions.

    • 9 months ago
  8. e.mccormick
    Best Response
    You've already chosen the best response.
    Medals 0

    In Python, yes. In C++ it is all about {}

    • 9 months ago
  9. Neec0
    Best Response
    You've already chosen the best response.
    Medals 0

    As well as Java.

    • 9 months 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.