Sunday 19 February 2023

Arithmetic operators

Arithmetic operators

The Arithmetic operations that we can perform in python are :
  • Addition 
  • Subtraction
  • Multiplication
  • Division
  • Floor division
  • Modular division
  • Exponent

Addition

The Addition operator adds two operands on both sides of the symbol +.  + symbol is used for the Addition operation.

a=10
b=100
print('Adition of two integers a and b is ',a+b)
Output
Adition of two integers a and b is  110

Subtraction

The Subtraction operation is performed on two operands and from the right operand the left operand is subtracted. - sign is used for the Subtraction operation.

a=13
b=7
print('Adition of two integers a and b is',a+b)
Output
Adition of two integers a and b is 20

Multiplication

The Multiplication operation multiplies the two operands a and b and a*b is same as b*a.  * sign is used for the Multiplication operation.

a=5
b=5
print('Multiplication of two integers a and b is',a*b)
Output
Multiplication of two integers a and b is 25

Division

Division operator divides the left side operator to the right side operator and returns the quotient .  / sign is used for the division operator.

a=15
b=3
print('Division of two integers a and b is',a*b)
Output
Division of two integers a and b is 5.0

Modular division

Modular division is same as division but returns the remainder.  % sign is used for the Modular division operation.

a=56
b=13
print('Modular division of two integers a and b is',a%b)
Output
Modular division of two integers a and b is 4

Floor division

Floor division divides the operands and returns the quotient and removes the decimal points after the integer.  // sign is used for the Floor division operator.

a=15
b=3
print('Floor division of two integers a and b is',a//b)
Output
Floor division of two integers a and b is 5

Exponent

Exponent operator raises the operand left to the power of the right operand. The  ** sign is Exponent operator.

a=4
b=3
print('Exponent of two integers a and b is',a**b)
Output
Exponent of two integers a and b is 64

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top