Saturday, December 7, 2019

PYTHON OPERATORS

# OPERATORS :-

As we all know that  the python is very powerful and most commonly used programming language in the whole world.So it provide many powerful operators. operators have the power to apply on the operands and manipulate their values according to the operation applied on them. 

In other words Operators are used to perform some specific operations on operands or we can say variables or values. Operators are either represented by keywords or special characters. For example for Identity operator we use keyword "is" and "is not".

EXAMPLE :- Suppose we have an expression  4+5=9 
                         Here 4 and 5 are operators and + is an operator which is applied on the operands to                               perform the operation of addition.




#TYPES OF OPERATORS :-

Basically python is very rich in operators. Some of the python operators listen below :-

1. Arithmetic Operators
2. Assignment Operators
3. Comparison Operators
4. Logical / Relational Operators
5. Identical Operators  
6. Membership Operators
7. Bit-wise Operators


#ARITHMETIC OPERATORS :-

Arithmetic operators are those which are used whit numeric values to perform common mathematical operations.

Suppose a=40 and b=20 then :-
OPERATORS
EXAMPLE
RESULT
+ Addition
X+Y
60
- Subtraction
X-Y
20
* Multiplication
X*Y
800
/ Division
X/Y
2
% Modulus
X%Y
0
** Exponent
X**Y
40 to the power 20

#ASSIGNMENT OPERATORS :-

Assignment operators are used to assign the values to the variables. Some of the Assignment operators are listen below.

Operator symbol
Example
Explanation
=
X=5
X=5
+=
X+=5
X=x+5
-=
x-=5
X=x-5
*=
X*=5
X=x*5
/=
x/=5
X=x/5
%=
X%=5
X=x%5

















# COMPARISON OPERATORS :-

The operators which are used to compare the values of two variables are called Comparison Operators. the comparison operators are listen below :-


Operator symbol
Name
Example
==
Equal
X==Y
!=
Not Equal
X!=Y
> 
Greater than
X>Y
                <
Less than
X<Y
>=
Greater than Equal
X>=Y
<=
Less than Equal
X<=Y

















#LOGICAL OPERATORS :-

These are the operators which are used to check the condition either it is true or false. Logical AND , logical OR , Logical NOT are the logical or relational operators  in python.


CONDITIONS FOR LOGICAL OPERATORS :-

  •  LOGICAL AND : It returns true only if both the conditions are true.
  • LOGICAL OR :     It returns  true if any of one condition is true.
  • LOGICAL NOT :   It returns  false if condition is true.
For example  suppose x=2 then :

OPERATORS
PROCESSING
RESULT
AND
x<5
AND
x<10
TRUE
OR
x>5
OR
x<10
TRUE
NOT
x<5
NOT
X<10
FALSE

 #IDENTITY OPERATORS :-

These are the operators which is use to check whether the variables are located at same memory location. If two variables are equal then it doesn't mean they are IDENTICAL.
python have two Identical operators "is" and "is not".

OPERATORS
DESCRIPTION
EXAMPLE
is
Returns true if both values are at same location.
X is Y
is not
Returns true if both values are not at same location.
X is not Y

 

# MEMBERSHIP OPERATORS :-

These are the operators which are used to check whether the variables/values are present in the sequence (string,list,tuple,etc.) or not.
"in" and "not in" are the python membership operators.

OPERATORS
DESCRIPTION
EXAMPLE
In
Returns true if both values are present
X in Y
Not in
Returns true if both values are not present
X not in Y



#BIT-WISE OPERATORS :-


A bit-wise operator is a character representing an action that works on data at the bit level rather than with bytes or large units of data.

Operator
Description
Example
& Binary AND
Operator copies a bit to the result if it exists in both operands
(a & b) (means 0000 1100)
| Binary OR
It copies a bit if it exists in either operand.
(a | b) = 61 (means 0011 1101)
^ Binary XOR
It copies the bit if it is set in one operand but not both.
(a ^ b) = 49 (means 0011 0001)
~ Binary Ones Complement
It is unary and has the effect of 'flipping' bits.
(~a ) = -61 (means 1100 0011 in 2's complement form due to a signed binary number.
<< Binary Left Shift
The left operands value is moved left by the number of bits specified by the right operand.
a << 2 = 240 (means 1111 0000)

INTODUCTION TO PYTHON

 # INTRODUCTION :- 

Python  is  a  popular  programming  language . It  was  created  by  GUDIO  VAN  ROSSUM   in  1991 . As  we  know  that  it  is  a  programming   language  but  it  is  very  advanced  and  easy  in  comparison  of  other programming  language  i.e.  C,  C++  etc.





# DEFINITION :-

Python  is  an  object-oriented , high-level , general perpus programming  language. It  is  designed  for  rapid  prototyping of  complex  problems  and  applications.  
It  has  very easy  and  simple  syntax  which  helps  in  development  process. It is  supported  by  all kind  of  OS (operating system). Just  because  of  this  is  large  companies  like:  NASA , Google , YouTube , BitTorrent , etc.



# USE OF PYTHON :-

Python  is  widely  used  programming  language . it  is  used  for  many  perpuses  most  of  them  are  listed  below :

1.It  is  used  for  Web  Development.
2.It  is  used  for  Software  Development.
3.It  is used for  Software  scripting.
4.It  is  used  for  App  Development.

# FEATURES OF PYTHON :-

1.Python  can  be  used  on  a  server  to  create  web  applications.

2.It  can  be  used  in  Data Base  management.

3.It  can  be  used  to  handle  big  data  files  and  perform  complex  mathematical  operations.

4.It  can  be  used  for  Rapid-Prototyping  or  for  production  ready  software  development.

# IMPORTANCE OF PYTHON :-

Python  can  be  work  on  many  different  platforms  like  Windows , MAC , Linux , pi , etc.
It  has  a  simple  syntax  similar  to  English language.
It  allows  Developers  to  write  programming  codes  in  fewer  lines  which  is  not  possible  in  any  other programming  Language.
It  runs  on  an  Interpreter  System  that  means  codes  can  be  executed  as soon  as  it  is written.
It  can  be  treated  in  a procedural  way , an   Object-Oriented  way  or  a  functional  way.