"""====================================================================== Program: Newtons Weight Calculator Author: Chris Brockamp Date: April 12, 2015 Dev Env: Python Fiddle Description: Gets the mass of an object from the user and then calculates and displays the object's weight in newtons. ======================================================================""" #_declare constant_______________________________________________________ GRAVITY = 9.8 #_define functions_______________________________________________________ def calculate_weight(mass): weight = mass * GRAVITY if weight < 10: print "The object's mass is too light to calculate its weight..." elif weight > 1000: print "The object's mass is too heavy to calculate its weight..." else: print "The object's weight is: " + str(weight) + " Newtons" #_main___________________________________________________________________ mass = input("Enter the object's mass in kilograms: ") print mass calculate_weight(mass)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question