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:
c= 3 + 4
variable1 = 4
sum_value = variable1 + variable2
print(4/2) # returns a value 4 divided by 2 i.e ans=2
print(21/4) # returns a decimal value of the resultant answer i.e ans=5.25
print(21//4) # returns the integer part of the answer i.e ans=5
print(21%4) # returns the remainder after division i.e ans =1
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.
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.