Recall the assignment operator. General view can be written in this way
variable = expression
The expression on the right side of the assignment operator allows you to calculate the values of variables using various formulas.
What expression can contain
• integers and real numbers (in real numbers, the integer and fractional parts are separated by a dot, not a comma, as is customary in mathematics)
• signs of arithmetic operations:
+
Addition
-
subtraction
*
Multiplication
/
Division
**
exponentiation
•calls to standard functions (we give only part of a large set. All mathematical functions are described in the math library, which must be connected using the
import math
string)
abs(n)
module of integer n
math.fabs(x)
modulus of a real number x
math.sqrt(x)
the square root of the real number x
math.pow(x,y)
computes x to the power of y
• parentheses to reorder
When changing the values of variables, it is convenient to use a shorthand notation
Full string |
Short string |
a = a + b |
a += b |
a = a - b |
a -= b |
a = a * b |
a *= b |
a = a / b |
a /= b |