Introduction
Text values
Variables
12. Expressions saved in variables
Functions
Summary

Instruction

Great! We're making good progress. Variables aren't just limited to storing a single hard-coded value. It's possible to assign the value of an entire expression to a variable. For example, if you want to store the value of an expression that converts someone's weight from kilograms to pounds, you can use the following syntax:

weight_pounds <- 50 * 2.2046

Just as before, the leftward-pointing arrow is used to assign the value of the expression to the variable on the left (named weight_pounds). The entire expression on the right is evaluated before it is stored in the variable. Calling the variable by its name will return the result of the computation (110.23).

Exercise

In one of the previous exercises, we converted Tanya's weight from kilograms to pounds. Let's do something similar for her height.

Assign the value of the expression that converts Tanya's height (172 cm) from centimeters to inches to a variable named height_inches (where 1cm = 0.39 inches).