I called all the methods so I'm not sure why they won't return anything?
this is my attempt:
train_mass = 22680
train_acceleration = 10
bomb_mass = 1
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_in_fahrenheight = c_to_f(0)
def get_force(mass, acceleration):
return mass*acceleration
train_force = get_force(train_mass, train_acceleration)
def get_energy(mass, c=3*10**8):
return mass * c**2
bomb_energy = get_energy(bomb_mass)
I was expecting the values in the method to be returned but nothing gets returned. Also, there were no errors.
From Python Principles:
Print vs. return in Python
Printing and returning are completely different concepts.
return
is a keyword. When areturn
statement is reached, Python will stop the execution of the current function, sending a value out to where the function was called. Usereturn
when you want to send a value from one point in your code to another.Using
return
changes the flow of the program. Using