Python – Operators – Arithmetic Operators

Operator:

  • It is a symbol
  • It performs operation on 1 or more operands
  • Operands nothing but values or variables‚Ķ

Arithmetic operators:

  • Operators are used to perform all arithmetic operations
  • Operators are +, -, *, / , %, // , **
  • Division(/) operator returns quotient value
  • Mod(%) operator performs operation only on integers and returns remainder
  • Floor division(//) returns floor value of quotient after division
  • Exponent(**) gives power value.
print(“Arithmetic operations”)
print(“5+2 :”, 5+2)
print(“5-2 :”, 5-2)
print(“5*2 :”, 5*2)
print(“5/2 :”, 5/2)
print(“5%2 :”, 5%2)
print(“5//2 :”, 5//2)
print(“5**2 :”, 5**2)
int a=10;                                 
a=20;
a=30;
a=40;
a=50;
print(a);
int a=5;                                       
a=a+1;
a=a+1;
a=a+1;
a=a+1;
print(a);
int a=5;                                       
a=a+1;
a=a+2;
a=a+3;
a=a+4;
print(a);
int a=15;                                       
a=a+5;
a=a+4;
a=a+3;
a=a+4;
print(a);
int a=5, x=1;                                
a=a+x;
x = x+1;
a=a+x;
x = x+1;                                       
a=a+x;
x = x+1;
a=a+x;
print(a, x);
int a=5, b=5;                                
a=a+b;
b = b-1;
a=a+b;
b= b-1;                                       
a=a+b;
b = b-1;
a=a+b;
print(a, b);
int n=2;                        
int s=n*n;
print(s);
int n=2;                      
int c=n*n*n;
print(c);
int n=2;                        
int s=n*n;
int c=n*n*n;
print(s+c);
int a=5, b=3;               
int c=a+b;
print(c);
int a=5, b=3;                       
a=b;
b=a;
print(a,b);
int a=5, b=3, c;            
c=a;
a=b;
b=c;
print(a,b);
int a=2, b=3;                    
a=a+b;
b=a+a;
print(a,b);
int a=2, b=3;                        
a=a+b;
b=a-b;
a=a-b;
print(a,b);
int a=2, b=3;                     
a=a*b;
b=a//b;
a=a//b;
print(a,b);
int n=234;                       
int d=n%10;
print(d);
int n=234;                      
int d=n//10;
print(d);
int bal=5000;                    
int amt=3500;
bal = bal + amt;
print(bal);
int sum=0, i=1;              
sum=sum+i;
i=i+1;
sum=sum+i;
i=i+1;
sum=sum+i;
i=i+1;
sum=sum+i;
print(sum);
int fact=1, i=1;                 
fact=fact*i;
i=i+1;
fact=fact*i;
i=i+1;
fact=fact*i;
i=i+1;
fact=fact*i;
print(fact);
int n=2345, rev=0;                   
rev=rev*10+n%10;
n=n//10;
Print(rev, n);
rev=rev*10+n%10;
n=n//10;
Print(rev, n);
rev=rev*10+n%10;
n=n//10;
Print(rev, n);
rev=rev*10+n%10;
n=n//10;
Print(rev, n);
Scroll to Top