In this lesson, we're going to introduce more operators. These are 1. Modulus, 2. Exponentiation, 3.Assignment operators and 4. Comparison operators.
The percentage symbol in Python is called the modulo operator, it yields the remainder when the first operand is divided by the second, it's used to get the remainder of a division problem.
This symbol in Python is called the exponentiation operator, it multiplies a number a certain number of times by itself. It's similar to the concept of power in math. In this example, it prints the result of four being multiplied by itself five times. T
he next operator we'll look at is called an assignment operator. These are used to assign values to variables. We covered this in lesson two when we looked at changing the value of a variable. assignment operators are also used to assign new valuables to variables using mathematical operators. In the examples, we assign a value to a variable, and then change that value by adding, subtracting, multiplying or dividing by itself, you can do some pretty cool things with assignment operators as they can be used alongside arithmetic operators to simplify our arithmetic operations.
Let's try this. Instead of writing the variable name twice, we drop it and shorten the statement. This is called shorthand. So what do you think the result will be?
When you want to compare two or more values, you can use a comparison operator. When comparing values, Python will return true or false. This is called a boolean value that we covered Boolean in datatypes. Here are some examples of comparison operators being used to compare two values.
Remember from the last lessons that strings are used to display text, including a word, a sentence, or even an entire paragraph, and that a string must be surrounded by quotation marks. I want to show you how to use the addition operator to combine two strings together. When combining two strings, it is called concatenation, a big word concatenation to concatenate a string and a variable they must be the same datatype use the str function to convert the number into a string.
We covered a lot of ground today. Good job