General question - how does the program know what the arguments refer to?

#1

So, I am almost done with this lesson, but can't figure out how the program knows what some of the arguments refer to.

For example, in this piece of code (spoiler alert):
if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
else:
return "F"

How does the program know what a "score" is? "Score" hasn't been defined earlier, so I'm just curious what is going on. Did I miss something?

#2

Interesting question @methodrunner50204

The program doesn't actually know what a score is. Its only doing the arithmetics you are asking it do for you

Your code defines a function called get_letter_grade that requires a single parameter which you have named "score".

The fact is that you could have named it any other name and it would still works

``````def get_me_lunch(food):
if food >= 90:
return "A"
elif food >= 80:
return "B"
elif food >= 70:
return "C"
elif food >= 60:
return "D"
else:
return "F"``````

This code would works and return a letter grade from any integer result you would ask him to evaluate.

The problem is, if someone would need to run your code, he would be quite confused. Asking him to call a function called "get_me_lunch()" and giving it an integer as "food" that returns a single uppercase letter as a result is quite confusing indeed

While they are essentials to readability and to our comprehension of the code, the names of your variable don't matter to the computer or to the python interpreter that analyses your code. All it cares about is numbers, the arithmetics it can do with them and if what you are trying to have it do respect the rules and logic of mathematics.