Quizz 3.24 Notes and Grading Program potential Problem.

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:

def myprocedure():
    print "Hello!"

But if you ask me to write a procedure that returns a value I will write

def myprocedure():
    return "Hello"

I want to write about this because in the Quizz 3.24 it says:

#Define a procedure, sum_list,
#that takes as its input a
#List of numbers, and produces
#as its output the sum of all

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.

asked 09 Mar '12, 17:44

Steven%20Sierra%20Forero-1's gravatar image

Steven Sierr...
94692341
accept rate: 10%


3 Answers:

Output is to return the value. Print is to print. That one wants you to return the value.

link

answered 09 Mar '12, 17:54

fnenu-1's gravatar image

fnenu-1 ♦♦
18.5k1981231

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.

(09 Mar '12, 18:04) Steven Sierr... Steven%20Sierra%20Forero-1's gravatar image

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.

(09 Mar '12, 18:17) fnenu-1 ♦♦ fnenu-1's gravatar image

Hmmm, A procedure that returns a value has much more potential than one that just prints something out.
You can assign the returned value to variable and then do some more manipulation. Like you might use it to generate an average etc. I think you can safely say that when one mentions the output of a procedure it is the value that is returned.

link

answered 09 Mar '12, 18:00

Marlen%20Waaijer's gravatar image

Marlen Waaijer
1077

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.

link

answered 09 Mar '12, 18:06

Uplink's gravatar image

Uplink
4782415

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,329
×684
×33
×21
×5

Asked: 09 Mar '12, 17:44

Seen: 126 times

Last updated: 09 Mar '12, 18:17