We can also do basic math with our variables or with numbers in general, whether integers or floats. Just use ‘+’ for addition, ‘-’ for subtraction, ‘*’ for multiplication, and ‘/’ for division.
print(5+7) number1 = 8.5 number2 = 9.3 divided_value = number1/number2 print(divided_value)
To work with exponents, use the ‘**’ operator followed by the degree for the number.
Test1 = 5 Test2 = Test1**2 print(Test2)
The Modulo Operator can be very useful for certain calculations. It returns the remainder of the division of two numbers.
test1 = 5 test2 = 3 test_r = test1%test2 print(test_r)
Here, the variable test_r takes the value of the remainder of 5 divided by 3. This is 2, so the output will be 2.
Moving on to the advanced properties of Strings.