# Python 3 Functions - Physics Class project

I’m very new here. This is my first post.
Here is the code of my try at the 3rd Lesson in Python: Functions.
Getting Ready for Physics Class.
I followed the instructions and it seems working, so I might have some code mistakes. Trying to grasp the concept of it

</
train_mass = 22680
train_acceleration = 10
train_distance = 100

bomb_mass = 1

#1
def f_to_c(f_temp):
c_temp = (f_temp - 32) * 5/9
return c_temp
#2
f100_in_celsius = f_to_c(100)
print(“100 Degree Temperature Fahrenheit is in Celsius:”, f100_in_celsius, “C”)
#3
def c_to_f(c_temp):
f_temp = c_temp * (9/5) + 32
return f_temp
#4
c0_in_fahrenheit = c_to_f(0)
print(“Zero Tempretature Celsius is in Fahrenheit:”, c0_in_fahrenheit, “F”)
#5
def get_force(mass, acceleration):
force= mass * acceleration
return force
#6

# print(get_force(train_mass, train_acceleration))

train_force = get_force(train_mass, train_acceleration)
print(train_force)
#7
print(“The GE train supplies " + str(train_force) + " Newtons of force.”)
#8
def get_energy(mass, c):
c = 3108
energy = mass * c
2
return energy
#9
bomb_energy = get_energy(bomb_mass, c= 3
10**8)
print(bomb_energy)
#10
print(“A 1kg bomb supplies " + str(bomb_energy) + " Joules.”)
#11
def get_work(mass, acceleration, distance):
work = get_force(mass, acceleration) * distance
return work
#12
train_work = get_work(train_mass, train_acceleration, train_distance)
print(train_work)
print(“The GE train does " + str(train_work) + " Joules of work over " + str(train_distance) + " meters.”)

Let me know if there are any mistakes.
Cheers,

It seems to be well laid out, with good use of variables. If this was production code, you might want to make the comments slightly more descriptive, but that’s ok.

In future, when you share code on the forums use the guidelines from this post.

1 Like