Learn Python: Functions I have a question


#1

I am supposed to get this in the text box: 32
226800

However, I don’t get that, I get an error code. Here is my error code:
32.0
Traceback (most recent call last):
File “script.py”, line 21, in
train_force = get_force(train_mass, train_accelaration)
NameError: name ‘train_accelaration’ is not defined

so the 32 is correct, but I get that error code instead of 226800

here is my actual code:

train_mass = 22680
train_acceleration = 10
train_distance = 100

bomb_mass = 1

def f_to_c(f_temp):
	return	(f_temp - 32) * 5/9

f100_in_celsius = f_to_c(100)

def c_to_f(c_temp):
	return	(c_temp * 9/5) + 32

c0_in_farenheit = c_to_f(0)
print(c0_in_farenheit)

def get_force(mass, accelaration):
  return mass * acceleration

train_force = get_force(train_mass, train_accelaration)
print("The GE train supplies " + str(train_force) + "Newtons of force.")

#2

typos are so frustrating, aren’t they? You made a typo in one of your variable.


#3

which one? twenty characters.


#4

given you get a name error for train_accelaration i think you should be able to pinpoint the typo? The error message also gives a line number


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.