# Basic Arithmetic Operations in Python3

05 min read

Note: In Python language, we use # for writing comments in the code:

Now, let us check the syntax for a few basic arithmetics operations in Python:

Addition >>

``Program starts``print(3+4)``#or``c= 3 + 4``print(c)``#or``variable1 = 4``variable2=3``sum_value = variable1 + variable2``print(sum_value)`output777`
`Subtraction>>print(7-4)print(7-3)Output34`
`Multiplication >>print(4*2)print(2*3)Output86`
`Division >>print(4/2)             # returns a value 4 divided by 2 i.e ans=2print(21/4)         # returns a decimal value of the resultant answer i.e ans=5.25print(21//4)        # returns the integer part of the answer i.e ans=5print(21%4)       # returns the remainder after division i.e ans =1Output25.2551`
`Power>>print(2**4)   # results the value of 2^4 i.e ans=16.# there is another method of computing the power of a number by importing math library (math.pow(x,y)). The use of libraries and functions are discussed in further articles.Output16`
`BODMAS rule:print((8+4)*3/6)        # to compute such questions, Python uses BODMAS rule meaning Brackets >> Of >>Division >> Multiplication >> Addition >>Subtraction. # Hence here, (8+4) is computed first since its inside brackets. Later 3/6 is calculated and later both calculated components are multiplied.Output6`

### Relevant exercises

POST A NEW COMMENT

• Input (stdin)

Output (stdout)

Input (stdin)

Your Output (stdout)

Expected Output

Compiler Message

Input (stdin)

`2    3`

Your Output (stdout)

`5`

Expected Output

`5`

Compiler Message

`5`