Python

Arithmetic Operation in Python

AKA.DM 2024. 9. 13. 07:44
반응형

The most basi arithmetic operations that can be done in Python are : Addition, Substration, Multipication and Division.

And these operations are performed using the following operations.

 

+ => Addition

- => Substration 

* => Multipication

/ => Division

 

You can use follwing operators to perform higher level arithmetic operations.

In the next lecture, we will examine what these operators do one by one.

 

% => Mod

// => Floor Division

** => Exponetiate

 

Mod is the remainder obatined by dividing a number by another number. It is performed using the % operator in Python.

For example, the remainder of dividing 29 by 7 is 1.

 

 

Another used operator in Python is the floor division operator. This gives us the full demical part of the result after a division.

In python, you can do this using the double slash // character.

 


Last operator to review is the double asterik. You can apply exponetiation with this operator.

 

We can perform arithemetic operations on a variable and equate it to itself.

We can also do the same operation like this:

We can put the operator of the arithmetic operation we want beofre the eqauls operator and create the new variable in a shorter time.

Note : you can do this with the operators used in all other arithmetic operations.

 

Arithmetic operations have an order of procedence. This order is as follows :

Parentheses > Exponents > Negative Numbers > Multipication and Division > Addition and Subtraction

반응형

'Python' 카테고리의 다른 글

Methods in Strings in Python  (0) 2024.09.24
Boolean Logic Expression in Python  (0) 2024.09.21
Eascape Sequence Opertations in Python  (0) 2024.09.20
Python Print Function  (0) 2024.09.19
Python Type Conversion  (0) 2024.09.11