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:

a++

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:

a+=3

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

a**=2

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

27 September 2023
Your own VPN Outline? Easily!
We are sharing the easiest way to install VPN Outline using ubuntu 20.04 as an example.
17 October 2023
Installing MikroTik RouterOS on a VPS-N server running ...
RouterOS is the operating system on which MikroTik equipment runs. RouterOS can also be installed on ...