Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

My first project, a force calculator..

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 :)
I post all my trades and alpha on Twitter. @SlayerXBT
Cool project, have fun on your journey learning programming :)
Good Start , keep going :D


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by RackenNov 8, 2019 12:59 PM 2 282 Nov 8, 2019 12:59 PM
Last Post: 0xDEAD10CC
[Python] by TISADec 2, 2017 09:03 AM 4 240 Dec 2, 2017 09:03 AM
Last Post: Gliese
[Python] by georgeziozasJan 17, 2015 01:25 AM 2 79 Jan 17, 2015 01:25 AM
Last Post: georgeziozas