volume = 1 # liter volume = 1000 # converting to cm**3 # densities (in g/cm**3) iron = 7.8 air = 0.0012 gasoline = 0.67 ice = 0.9 human_body = 1.03 silver = 10.5 platinum = 21.4 print '''The mass of one liter of substance (in grams): Iron %.2f Air %.2f Gasoline %.2f Ice %.2f Human Body %.2f Silver %.2f Platinum %.2f ''' % (volume*iron, volume*air, volume*gasoline, volume*ice, volume*human_body, volume*silver, volume*platinum) ''' Sample run: The mass of one liter of substance (in grams): Iron 7800.00 Air 1.20 Gasoline 670.00 Ice 900.00 Human Body 1030.00 Silver 10500.00 Platinum 21400.00 '''
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