You are a physics teacher 👨🏫 preparing for the upcoming semester. You want to provide your students with some functions that will help them calculate some fundamental physical properties.
- Temp (C) = (Temp (F) - 32) * 5/9
- Temp (F) = Temp (C) * (9/5) + 32
- train_mass = 22680
- train_acceleration = 10
- train_distance = 100
- bomb_mass = 1
-
Write a function called
f_to_cthat takes an inputf_temp, a temperature in Fahrenheit, and converts it toc_temp, that temperature in Celsius. It should then returnc_temp. -
Let’s test your function with a value of 100 Fahrenheit. Define a variable
f100_in_celsiusand set it equal to the value off_to_cwith 100 as an input. -
Write a function called
c_to_fthat takes an inputc_temp, a temperature in Celsius, and converts it tof_temp, that temperature in Fahrenheit. It should then returnf_temp. -
Test your function with a value of 0 Celsius. Define a variable
c0_in_fahrenheitand set it equal to the value ofc_to_fwith 0 as an input. -
Define a function called
get_forcethat takes in mass and acceleration. It should return mass multiplied by acceleration. -
Test
get_forceby calling it with the variablestrain_massandtrain_acceleration. Save the result to a variable calledtrain_forceand print it. -
Print the string “The GE train supplies
XNewtons of force.”, withXreplaced bytrain_force. -
Define a function called
get_energythat takes in mass and c. c is a constant that is usually set to the speed of light, which is roughly 3 x 10^8. Set c to have a default value of 3*10**8.get_energyshould return mass multiplied by c squared. -
Test
get_energyby using it onbomb_mass, with the default value of c. Save the result to a variable calledbomb_energy. -
Print the string “A 1kg bomb supplies
XJoules.”, withXreplaced by `bomb_energy**. -
Define a final function called
get_workthat takes in mass, acceleration, and distance. Work is defined as force multiplied by distance. First, get the force usingget_force, then multiply that by distance. Return the result. -
Test
get_workby using it ontrain_mass,train_acceleration, andtrain_distance. Save the result to a variable calledtrain_work. -
Print the string "The GE train does
XJoules of work overYmeters.", withXreplaced withtrain_workandYreplaced withtrain_distance.
