bramas
  • bramas
What does it mean when code is said to be "outside a function?"
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
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.
rsmith6559
  • rsmith6559
In Python, there's a very good chance that it comes from an indentation error.
bramas
  • bramas
Thank you neec() but what does 'outside' or 'inside' of a function mean? rsmith6559 - thanks I'll look out for the indentation error.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
@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
anonymous
  • anonymous
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.
e.mccormick
  • e.mccormick
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.
bramas
  • bramas
Thanks a lot! I get it now. It really comes down to proper indentation of expressions under their relevant functions.
e.mccormick
  • e.mccormick
In Python, yes. In C++ it is all about {}
anonymous
  • anonymous
As well as Java.

Looking for something else?

Not the answer you are looking for? Search for more explanations.