Articles → Python → Mathematical Operator In Python

Mathematical Operator In Python






Mathematical Operator




  1. Add operator (+)→ This operator is used to add 2 numbers.
  2. Subtract operator (-)→ This operator is used to subtract one number from other.
  3. Multiply operator (*)→ This operator is used to multiply 2 numbers.
  4. Divide operator (/)→ This operator is used to divide 2 numbers.
  5. Modulus operator (%)→ This operator returns the reminder when one number is divided by other. For example, if 10 is divided by 3 then 1 will be the reminder.
  6. Exponent operator (**)→ This operator is used to perform exponential calculation on operand. For example, 32 is written as 3 **2 in python which is calculated as 2 times 3 i.e. 3 * 3 which is equal to 9.
  7. Floor division (//)→ This operator will provide the result of division 2 numbers after removing decimal. For example, if we divide 11 by 3 then result of division would be 3.66. After removing the decimal, the result would be 3.

Example




operand1 = 3
operand2 = 2

print ("addition:", operand1 + operand2) #addition
print ("subtraction:", operand1 - operand2) #subtraction
print ("multiplication:", operand1 * operand2) #multiplication
print ("division:", operand1 / operand2) #division
print ("modules:", operand1 % operand2) #modules
print ("exponent:", operand1 ** operand2) #exponent
print ("Floor division:", operand1 // operand2) #Floor division




Picture showing the output of the Mathematical operator in python

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, February 15, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250