 In the python 3 exercise “Getting Ready for Physics Class” (link in post title), on step 9 I am asked to ‘Test `get_energy` by using it on `bomb_mass` , with the default value of `c`. …’

In step 9 when I test ‘get_energy’
If I write:

bomb_mass = 1

def get_energy(mass, c=3 * 10 ** 8):
return(mass * c ** 2)

print(get_energy(bomb_mass))’

The result I get is: The correct answer printed to the console of 90000000000000000
As I understand it I do not need to enter a second value after bomb_mass in the print() function because it will seek to fill the second variable which is already set up as a default in the def_function line

However
If I enter the variable c = 310**8 in the heading section of the scrypt.py document I assume that the default value of c in this document will be set to 310**8. Is this correct?

Assuming it is then the follow up question that I’m ultimately trying to get answered is as follows.
If I write:

bomb_mass = 1
c = 3 * 10 ** 8

def get_energy(mass, c):
return(mass * c ** 2)

print(get_energy(bomb_mass))

The result I get is: a type error indicating a positional argument for c
Why is it that in this version c is not being filled in from the default value for c at the heading section of the scrypt.py document where I defined it?

For anyone that can help, thank you for taking the time to do so.

That’s because the `c` in the “header” is a different variable, which has no relationship to the `c` parameter of the `get_energy` function.

Ok,
Renamed header line to light_speed=3*10**8 and then used

print(get_energy(bomb_mass, light_speed))

Which resulted in the correct answer being printed to console.

It sort of makes sense to me how the above works, however why is c in the “header” seen as a different variable, as opposed to having a relationship to `c` in the `get_energy` function?

Is there a better term than “header” I can use to describe this area for the future?

Roughly speaking (ignoring certain situations for now) the names you create in one function cannot be accessed outside that function, they are lost as soon as the function returns.

Q2: In Python you’d be dicussing namespace and scope. You’ve assigned `3*10**8` to the name `light_speed` in the current/local namespace.