In this video, we'll cover Expressions and Variables.

Expressions describe a type of operation the computers perform.

Expressions are operations the python performs, for example,

basic arithmetic operations like adding multiple numbers.

The result in this case is 160.

We call the numbers operands and the math symbols in this case,

addition, are called operators.

We can perform operations such as traction using the subtraction sign.

In this case the result is a negative number.

We can perform multiplication operations using the asterisk, The result is 25.

In this case, the operands are given by negative and asterisk.

We can also perform division with the forward slash.

25 / 5 is 5.0.

25 / 6 is approximately 4.167.

In Python 3 the version we will using in this course, both will result in a float.

We can use double slash for integer division, where the result is rounded.

Be aware, in some cases the results are not the same as regular division.

Python follows mathematical conventions when performing mathematical expressions.

The following operations are in a different order.

In both cases Python performs multiplication

then addition to obtain the final result.

There are a lot more operations you can do with Python, check the labs for

more examples.

We will also be covering more complex operations throughout he course.

The expressions in the parenthesis are performed first.

We then multiply the result by 60.

The result is 1,920.

Now, let's look at variables.

We can use variables to store values, in this case, we assign a value of 1 to

the variable my_variable using the assignment operator, i.e, the equal sign.

We can then use the value somewhere else in the code

by typing the exact name of the variable.

We will use a colon to denote the value of the variable.

We can assign a new value to my_variable using the assignment operator.

We assign a value of 10, the variable now has a value of 10.

The old value of the variable is not important.

We can store the results of expressions, for example, we add several values and

assign the result to x, x now stores the result.

We can also perform operations on x and save the result to a new variable, y.

Y now has a value of 2.666.

We can also perform operations on x and assign the value x.

The variable x now, has a value, 2.666.

As before, the old value of x is not important.

We can use the type command in variables as well.

It's good practice to use meaningful variable names, so

you don't have to keep track of what the variable is doing.

Let say, we would like to convert the number of minutes

in a highlighted examples to number of hours in the following music dataset.

We call the variable that contains the total number of minutes total_min.

It's common to use the underscore to represent the start of a new word,

you could also use a capital letter.

We call the variable that contains the total number of hours, total_hour.

We can obtain the total number of hours by dividing total_min by 60.

The result is approximately 2.367 hours.

If we modify the value of the first variable,

the value of the variable will change.

The final result values change accordingly, but

we do not have to modify the rest of the code.