Use print function without quotes. Output will be calculated answer.
+ Addition
- Subtraction
/ Floating point division
* Multiplication
Single slash / : Floating point division
-------------------------------------------------
Double slash / / : Integer division
-------------------------------------------
Integer division gives answer in the minimal integer...
Double star ** : Power
------------------------------
Round function :
-----------------------
(1) print ( round ( multiplication ) )
(2) print ( round ( multiplication , How many digits after decimal ) )
Precedence Rule :
If we calculate directly 2 + 3 - 4 / 5 * 6
Python gives Answer 0.1999 by BODMAS rule.
Bracket Order Division Multiplication Addition Subtraction
But if we add brackets to different operations, answer will be different.
How this ?
That's because python uses Precedence Rule.
First priority Parenthesis
Second priority Exponent ( Powers, square, root )
1 ) Parenthesis : Highest
--------------------------------
That means brackets.
Python gives first priority to brackets.
( 3 + 2 ) = 5
2 / 5 = 0 . 4
2 ) Exponent : Right to Left
------------------------------------
Power , square , cube , square root ... etc.
Eg. 2 raise to 3 raise to 2
Exponents calculates right to left. That is first calculate
3 ** 2 = 9 ( Square of 3 )
2 ** 9 = 512 ( 9 th power of 2 )
3 ) * , / , // , % : Left to right
-------------------------------------------
Multiplication, Point division, Integer division, Modulo
Eg. 25 / 2 * 3 % 4
Calculation works from Left to Right
25 / 2 = 12 . 5
12.5 * 3 = 37.5
37.5 % 4 = 1 . 5
4 ) + , - : Left to right
-------------------------------------------
Addition , Subtraction
Eg. 5 + 3 - 2 + 4
Calculation works from Left to Right
5 + 3 = 8
8 - 2 = 6
6 + 4 = 10
+ Addition
- Subtraction
/ Floating point division
* Multiplication
Single slash / : Floating point division
-------------------------------------------------
Double slash / / : Integer division
-------------------------------------------
Integer division gives answer in the minimal integer...
Double star ** : Power
------------------------------
Round function :
-----------------------
(1) print ( round ( multiplication ) )
Precedence Rule :
If we calculate directly 2 + 3 - 4 / 5 * 6
Python gives Answer 0.1999 by BODMAS rule.
Bracket Order Division Multiplication Addition Subtraction
But if we add brackets to different operations, answer will be different.
How this ?
That's because python uses Precedence Rule.
First priority Parenthesis
Second priority Exponent ( Powers, square, root )
Third priority * / // % ( Multiplication, Division )
Fourth priority + - ( Addition, Subtraction )
1 ) Parenthesis : Highest
--------------------------------
That means brackets.
Python gives first priority to brackets.
( 3 + 2 ) = 5
2 / 5 = 0 . 4
2 ) Exponent : Right to Left
------------------------------------
Power , square , cube , square root ... etc.
Eg. 2 raise to 3 raise to 2
Exponents calculates right to left. That is first calculate
3 ** 2 = 9 ( Square of 3 )
2 ** 9 = 512 ( 9 th power of 2 )
3 ) * , / , // , % : Left to right
-------------------------------------------
Multiplication, Point division, Integer division, Modulo
Eg. 25 / 2 * 3 % 4
Calculation works from Left to Right
25 / 2 = 12 . 5
12.5 * 3 = 37.5
37.5 % 4 = 1 . 5
4 ) + , - : Left to right
-------------------------------------------
Addition , Subtraction
Eg. 5 + 3 - 2 + 4
Calculation works from Left to Right
5 + 3 = 8
6 + 4 = 10