Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 818 Bytes

Expressions-and-variables-basic-variables-Python.md

File metadata and controls

23 lines (20 loc) · 818 Bytes
layout topic title language
exercise
Expressions and Variables
Basic Variables
Python

Here is a small program that converts a mass in kilograms to a mass in grams and then prints out the resulting value.

mass_kg = 2.62
mass_g = mass_kg * 1000
print(mass_g)

Modify this code to create a variable that stores a body mass in pounds and assign it a value of 3.5 (about the right size for a Desert Cottontail Rabbit – Sylvilagus audubonii). Convert this value to kilograms (we are serious scientists after all). There are approximately 2.2046 lbs in a kilogram, so divide the variable storing the weight in pounds by 2.2046 and store this value in a new variable for storing mass in kilograms. Print the value of the new variable to the screen.