So, we see that Python can work with at least two types of data - numbers and strings. Numbers are written as a sequence of digits; there may also be a minus sign in front of the number, and strings are written in single quotes. 2 and '2' are different objects, the first object is a number and the second is a string. The + operation works differently for integers and for strings: for numbers it is addition, and for strings it is concatenation.
In addition to integers, there is another class of numbers: real numbers, represented as decimal fractions. They are written using a decimal point, for example 2.0. In a sense, 2 and 2.0 have equal meaning, but they are different objects. For example, you can evaluate the expression 'ABC' * 10 (repeat the string 10 times), but you cannot evaluate 'ABC' * 10.0.
You can determine the type of an object using the type function:
>>> type(2)
<class 'int'>
>>> type('2')
<class 'str'>
>>> type(2.0)
<class 'float'>
Please note type() is a function, the function's arguments are given in parentheses after its name.
Here is a list of basic operations for numbers:
A + B - sum;
A - B - difference;
A * B - product;
A/B - private;
A**B - exponentiation.
It's useful to remember that the square root of x is x**0.5, and the root of n is x**(1/n).
There is also a unary version of the operation -, that is, an operation with one argument. It returns the opposite number of the given one. For example: -A.
An expression can contain many operations in a row. How is the order of action determined in this case? For example, what would 1 + 2 * 3 ** 1 + 1 be equal to? In this case, the answer will be 8, since the exponentiation is performed first, then the multiplication, then the addition.
More general rules for determining the priorities of operations are as follows:
Basic operations on strings:
A + B - concatenation;
A * n - repeat n times, value n must be an integer type.