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 remainder when one number is divided by the 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 calculations on an 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 the decimal. For example, if we divide 11 by 3 then the 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



Output


Picture showing the output of the Mathematical operator in python



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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250