|
Hello, just to say if I understand this wrong, if you ask me for write a procedure that produces an output i will write this code:
But if you ask me to write a procedure that returns a value I will write
I want to write about this because in the Quizz 3.24 it says:
So i wrote my procedure just printing out the result of the sum of the list, not returning it, just to follow those instructions, but something happened when I tried to submit my code, that was, Try Again! I this the way grading program is evaluating our code hence marking it as incorrect? The question is, an output is to print out any value to the screen or an output is return a value?, or both?, in that case how could you realize which one is different? Just a Question, tell me if I'm wrong. |
|
Output is to return the value. Print is to print. That one wants you to return the value. Okay could make a poll and realize that most of the people say that an output is to return a value, but there comes the question, because some of the homeworks you could be asked to ouput a value meaning to print it out on the screen. Just to spread this misunderstood concept, from here everything asked to be and output, will be a procedure that return something. As @Uplink says, the way it's been talked about in this course is in terms of input-output where output is return, and print is something else. I think the whole concept of return and print hasn't been understood by a lot of people. |
|
Hmmm, A procedure that returns a value has much more potential than one that just prints something out. |
|
If you rewind to the video that introduced procedures, you'll see that a procedure "takes inputs and produces outputs", or something to that effect. You'll notice a certain mathematical taint in the classes. In programming terms, they should say "the procedure returns this and that" rather than "produces outputs". Once you realise this little bias, it gets easier. |