2
votes

Is there a difference in the Python nomeclature wherein a function taking input is different than a function taking an argument?

Isn't the input (i.e. the data you would have a function "process") the same as when you pass an argument to a function?

The reason I'm asking is Codeacademy has a tutorial that asks the student:

Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number's digits.

For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.

(Assume that the number you are given will always be positive.)

Isn't input in this sense the same as an argument?

Codeacademy is notorious for its poorly written tutorials, so just checking.

4
They are interchangeable really. - Martin Konecny
@MartinKonecny Ok, thanks - AdjunctProfessorFalcon
Now I think it's a good question because it led to more than one simple answer that seemed obvious from the quoted tutorial text. - Wolf

4 Answers

4
votes

The inputs to a function are not only the arguments. The function arguments are just one form of input that a function can take. Some functions take other types of inputs. So an input is more general than an argument.

A function can take input from a file or network socket or from a global or module variable.

A class or instance method of a class can also take input from class or instance variables on that same class.

However, in this particular context, the question appears to be using the two interchangeably.

3
votes

I think the term input is too ambiguous to equate to argument. Object methods could use object members as input, but these would not be passed in as arguments. Also, arguments can be outputs (e.g. an array which is filled by the method).

1
votes

I guess you are confusing the expressions.

The input(s) of a function is (are) the value(s) you pass as argument(s).

1
votes

It's the same term: The actual input of a function is the argument(s) passed when calling it.

Edit: As I learned, there are more than one answer to the question what input may mean to a function. However, in the case of this basic tutorial the simple answer is appropriate.