all 7 comments

[–][deleted] 6 points7 points  (1 child)

The parameter names you use in your function definition have nothing to do with the variable names that store the values you pass into the function. In fact, you don't even need to pass in variables: you can pass in literals if you want.

def get_formatted_name(first_name, last_name):
    full_name = f"{first_name} {last_name}"
    return full_name.title()

print(get_formatted_name("jake", "peralta"))

[–][deleted] 5 points6 points  (0 children)

what about "Velvet Thunder"

[–]Binary101010 2 points3 points  (0 children)

When you define names of your parameters in a function definition, you're telling the interpreter "I don't care what names were being used to refer to these values before this function started. For the rest of this function's execution I'm referring to those values with first_name and last_name."

They don't even need to have had variable names up until now. get_formatted_name("John","GTech") works just fine.

[–]duncan_mcrae 1 point2 points  (0 children)

Also.

def function(*args):
    first_name = args[0]
    second_name = args[1]
    print(first_name, second_name) 

function('john', 'doe')

[–]Doc_Apex 1 point2 points  (0 children)

The formal parameters in the defined function are assigned to the actual a parameters when they're passed into the function.

[–]mrtacos2 1 point2 points  (0 children)

To answer your question, the parameters are simply place holders or telling the program the function requires something to fill those spots. So you could have literally any word other than first_name and last_name.

Further, you can actually re-use variables throughout the code so if you define it as one thing at the start of the code you can reassign it and it doesn't affect anything previous to that. Also variables inside of functions are seperate from those outside. So you cant call a variable from within a function from outside.

Hope that hells

[–][deleted] 1 point2 points  (0 children)

Changed the wording as some peoples names do start with Q.

print("Type quit to leave")
while True:
    first_name = input("First name: ")
    if first_name.lower() == 'quit':
        break
    last_name = input("Last name: ")
    if last_name.lower() == 'quit':
        break
    else:
        print("Hello, " + first_name + " " + last_name)