Simplified arithmetic operations in Python

Mathematical transformations are an integral part of every computer program. Python is no exception to this rule. Language is ideal for a fairly wide range of mathematical problems.

As you know, Python allows you to apply all the basic arithmetic operations: addition, multiplication, subtraction, division, taking the remainder, powers and so on. The B-like language has the ability to simplify the arithmetic operations. You can record increase in the number per unit as follows:


Python also allows you to simplify the code and make it more concise. For example, you can write the expression "a = a + 3" as follows:


This account is used for all arithmetic operations. For example, for the construction of the power you can use the following expression:


In this example, the variable a is erected in the 2nd degree. The process of calculation is the same as write "a = a ** 2", but makes the code more readable and concise.

The main difference between the language of the Python-like C-language  in this case is the lack of unity of addition or subtraction by the characters "++" and "--".

5 February 2017

You may be interested in