Hack Forums
[Python] My first project, a force calculator.. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] My first project, a force calculator.. (/showthread.php?tid=6090995)



My first project, a force calculator.. - LSD - Jun 28, 2020

My first free form project on Codeacademy.. a simple calculator.

Code
train_mass = 22680
train_acceleration = 10
train_distance = 100
bomb_mass = 1
#
#
#
def get_force(mass, acceleration):
 return mass*acceleration
train_force = get_force(train_mass, train_acceleration)

print("The GE train supplies " + str(train_force) + " Newtons of Force.")

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

print("A 1kg bomb supplies " + str(bomb_energy) + " Joules.")

def get_work(mass, acceleration, distance):
 return get_force(mass,acceleration)*distance
train_work=get_work(train_mass, train_acceleration, train_distance)

print("The GE train does "+str(train_work)+" Joules of work over "+str(train_distance)+" meters.")

The output for the defined variables is:
Quote:The GE train supplies 226800 Newtons of Force.
A 1kg bomb supplies 90000000000000000 Joules.
The GE train does 22680000 Joules of work over 100 meters.


But you can input any numbers and it will output the proper calculations using the correct formula :)


RE: My first project, a force calculator.. - 4Txe4y33C9zvNhMj - Jun 29, 2020

Cool project, have fun on your journey learning programming :)


RE: My first project, a force calculator.. - greasyAlessandra - Jul 15, 2020

Good Start , keep going :D