Getting ready for Physics Class


I dont have any idea why i get an error from here. I follow the instructor exactly

could you advise ?



Pretty much as the error says, train_mass is not defined. Check your code to ensure that you have defined train_mass somewhere prior to the function call and that it has been assigned a value.

no this one is want to re-assign the code.

like mass ==> train_mass it should be working right?

Could you please post your entire code here so I can see it? The error is stating that train_mass is not defined, and so either it’s not listed above, or perhaps when defining that variable there was a typo made and that’s why it isn’t being passed into the function call.

1 Like


is that okay ??

def f_to_c(f_temp):

c_temp= (f_temp -32)* 5/9

return c_temp

f100_in_celsius = f_to_c(100)


def c_to_f(c_temp):

f_temp = c_temp*(9/5)+32

return f_temp

c0_infahrenheit= c_to_f(0)


def get_force(mass, acceleration):

return mass* acceleration

train_force = get_force(train_mass, train_acce3leration)


print(“The GE train supplies” + str(train_force)+ “Newtons of force.”)

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

return mass * c

bomb_energy=get_energy(bomb_mass, c)

print( “A 1kg bomb supplies X Joules., with”+ str(bomb_energy) + “replaced by bomb_energy.”)



Yes that’s great thank you. The problem is that both train_mass and train_acceleration have not been defined, so there are no values to be read into the function. You need to assign train_mass and train_acceleration with values before they can be used inside the function call. Also an extra note is just to be careful that you have typoed train_acceleration as train_acce3leration so be sure to correct that before running. For example, you should have something like this:

train_mass = 100000
train_acceleration = 30
train_force = get_force(train_mass, train_acceleration)
# will return 3000000
1 Like