1

I am new to python I am currently enrolled in beginner python at my local college. This is a requirement for my ICS degree. I had a quiz yesterday with the question "What of the following is an argument. I know that def register_for_class(studen_id, crn): is the parameter, and I know the function call is the argument but is anything else considered an argument? My teacher won't tell me. she just says that there is more than function call as an argument.

def register_for_class(student_id, crn): # parameter
    add_class(student_id, crn, 2022, 'Spring')
    student_name = get_name(student_id)
    class_name = get_class(crn)
    msg = student_name + ' is now enrolled in: ' + class_name
    return msg

register_for_class(19283746, 22319) # function call 
5
  • In my opinion argument and parameter are synonymous. The arguments/parameters in your example are 19283746 and 22319 Commented Oct 5, 2021 at 18:08
  • Your answer to your teacher was correct. I mean, even the documentation uses parameters/arguments interchageably, "The actual parameters (arguments) to a function call are introduced in the local symbol table of the called function when it is called" - a little more verbose than necessary, but it makes the slight distinction clear that a function call passes arguments to the function definition to match them with the definitions parameters. Commented Oct 5, 2021 at 18:30
  • Also, (as a memory aid) I think the naming of the terms kind of helps in that function calls "argue" with their function definitions by passing their "arguements", then the function definitions have parameters that must be properly aligned with and matched exactly or the function call will "fail" returning an "error message". Commented Oct 5, 2021 at 18:37
  • I emailed my teacher, with an explanation of the argument and parameter, she wouldn't give me a straight answer. She never does, it's infuriating. This was her response. ""You're correct here! def register_for_class (student_id, crn): # Isn't this the parameter? register_for_class(19283746, 22319) # isn't this the argument that is going to be passed through the parameter? However, look through the rest of the code for any that you might be missing."" Commented Oct 6, 2021 at 22:09
  • 1
    In addition to the great answer below, you can look at the Mozilla docs which has a great explanation of the difference that might help you understand better. Commented Oct 6, 2021 at 23:42

1 Answer 1

5

Parameters are the variable names that appear in a function definition, so in your example:

def register_for_class(student_id, crn):

student_id and crn are parameters.

Arguments are the values that you pass to a function when calling it, so when you call:

register_for_class(19283746, 22319)

19283746 and 22319 are arguments.

There are also several function calls made inside the register_for_class function definition, so if your teacher says there are more arguments, she probably means those. For example:

add_class(student_id, crn, 2022, 'Spring') # four arguments passed here

Note 1: A variable can be both a parameter and an argument (e.g., student_id above).

Note 2: Many people use the terms parameter and argument interchangeably. The definitions I give above are technically correct, but you should know that most people don't draw a distinction between the two in conversation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.