
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialThe term operator refers to a symbol (or sometimes a phrase of alphabets) which is predefined to perform a certain process such as addition, comparison etc. Each symbol requires one or more objects for the process to be performed. The objects are called operands and symbol itself is called operator. Most of the operators are binary in nature, in the sense they require two operands. Unary operator requires only one operand.
Everybody is familiar with arithmetic operators performing addition, subtraction, multiplication and division. Python has additionally modulus exponent and floor operators.
Operator | Purpose | Description |
|---|---|---|
+ | Addition | Adds operands on either side of the operator. |
- | Subtraction | Subtracts right hand operand from operand on left. |
* | Multiplication | returns Multiplication of values on either side of the operator. |
/ | Division | left operand acts as numerator and right operand denominator for division |
| % | Modulus | returns remainder of division of left hand operand by right. |
** | Exponent | Calculates value of operand raised to right. a**3 is a raised to 3 i.e. a*a*a |
// | Floor Division | The division of operands where the result is the quotient in which the digits after the decimal point are removed. But division is negative, the result is floored, i.e., rounded away from zero (towards negative infinity). |
In [1]:
a,b=21,10
#addition
a+b
Out[1]:
31
In [2]:
#subtraction
a-b
Out[2]:
11
In [3]:
#multiplication
a*b
Out[3]:
210
In [4]:
#division
a/b
Out[4]:
2.1
In [5]:
#modulus
a%b
Out[5]:
1
In [6]:
#floor of positive division
a//b
Out[6]:
2
In [7]:
#floor of negative division
-a//b
Out[7]:
-3
These operators allow any arithmetic operation and assignment in one step. Result of corresponding arithmetic operation of two operands is assigned back to left operand.
symbol | purpose | Description |
|---|---|---|
= | assignment | Assigns values from right side operands to left side operand |
+= | Add AND assign | adds right operand to the left and assign result to left operand |
-= | Subtract AND assign | subtracts right operand from left and assign the result to left operand |
*= | Multiply AND assign | multiplies right operand with left and assign result to left operand |
/= | Divide AND assign | divides left operand with right and assign result to left operand |
%= | Modulus AND assign | assigns modulus of two operands and assigns result to left operand |
**= | Exponent AND assign | Performs exponentiation of left operand by right and assign result to the left operand |
//= | Floor Division and assign | It performs floor division on operators and assign value to the left operand |
In [14]:
a,b=21,10
#add and assign
a+=b
a
Out[14]:
31
In [15]:
a,b=21,10
#subtract and assign
a-=b
a
Out[15]:
11
In [16]:
a,b=21,10
#multiply and assign
a*=b
a
Out[16]:
210
In [17]:
a,b=21,10
#divide and assign
a/=b
a
Out[17]:
2.1
In [18]:
a,b=21,10
#modulus and assign
a%=b
a
Out[18]:
1
In [19]:
a,b=21,10
#exponent and assign
a**=b
a
Out[19]:
16679880978201
In [20]:
a,b=21,10
#floor and assign
a//=b
a
Out[20]:
2
In order to compare two objects for equality or to decide whether one is greater than other etc. the logical comparison operators are used. Primarily used with numeric objects, they can very well be used with other Python objects such as string, list or tuple.
Symbol | purpose | Description |
|---|---|---|
== | equals | returns true if both operands are equal false otherwise |
!= | not equal to | returns true if both operands are not equal false otherwise |
> | greater than | returns true if left operand is greater than right operand, otherwise false |
< | less than | returns true if left operand is less than right operand, otherwise false |
>= | greater than or equal to | returns true if left operand is greater or equal to right operand, otherwise false |
<= | less than or equal to | returns true if left operand is less than or equal to right operand, otherwise false |
In [8]:
a=21
b=10
# equals
a==b
Out[8]:
False
In [9]:
#not equal to
a!=b
Out[9]:
True
In [10]:
#greater than
a>b
Out[10]:
True
In [11]:
#less than
a<b
Out[11]:
False
In [12]:
#greater than or equal
a>=b
Out[12]:
True
In [13]:
#less than or equal to
a<=b
Out[13]:
False
This category of operators is common to all sequence data type i.e. string, list and tuple. All of them use zero based index to access items in them. Hence operators for indexing and slicing have been commonly defined.
symbol | purpose | Description |
|---|---|---|
+ | Concatenation | Appends second sequence to first |
* | Repetition | concatenates multiple copies of the same sequence |
[] | Slice | Gives the item at given index |
[ : ] | Range Slice | fetches item in range specified by two index operands separated by : symbol. If first operand is omitted, range starts at zero index If second operand is omitted, range goes upto end of sequence |
in | Membership | Returns true if a item exists in the given sequence |
not in | Membership | Returns true if a item does not exist in the given sequence |
In [21]:
s1,s2="Hello","World"
l1,l2=[1,2,3],[4,5,6]
t1,t2=(1,2,3),(4,5,6)
In [22]:
#concatenation
print (s1+s2)
print (l1+l2)
print (t1+t2)
HelloWorld
[1, 2, 3, 4, 5, 6]
(1, 2, 3, 4, 5, 6)
In [23]:
#repetition
print (s1*3)
print (l1*3)
print (t1*3)
HelloHelloHello
[1, 2, 3, 1, 2, 3, 1, 2, 3]
(1, 2, 3, 1, 2, 3, 1, 2, 3)
In [24]:
#slice
print(s2[2])
print (l2[2])
print (t2[2])
r
6
6
In [25]:
s1='Hello World'
l1=[1, 2, 3, 4, 5, 6]
t1=(1, 2, 3, 4, 5, 6)
In [26]:
#range slice of string
print (s1[2:5])
print (s1[:3])
print (s1[4:])
llo
Hel
o World
In [27]:
#range slice on list
print (l1[2:4])
print (l1[:3])
print (l1[3:])
[3, 4]
[1, 2, 3]
[4, 5, 6]
In [28]:
#range slice on tuple
print (t1[2:4])
print (t1[:3])
print (t1[3:])
(3, 4)
(1, 2, 3)
(4, 5, 6)
In [29]:
s1='Hello World'
l1=[1, 2, 3, 4, 5, 6]
t1=(1, 2, 3, 4, 5, 6)
In [30]:
'He' in s1
Out[30]:
True
In [31]:
'W' not in s1
Out[31]:
False
In [32]:
10 in l1
Out[32]:
False
In [33]:
100 not in l1
Out[33]:
True
In [34]:
10/2 in t1
Out[34]:
True
In [35]:
10/3 not in t1
Out[35]:
True
These operators are specifically designed for performing operations on set data type as defined in set theory of Mathematics.
purpose | description |
|---|---|
Union | Union of two sets is a set of all elements in both. |
Intersection | Intersection of two sets is a set containing elements common to both |
Difference | Difference of two sets results in a set containing elements only in first but not in second set. |
Symmetric difference | Result of Symmetric difference is a set consisting of elements in both sets excluding common element |
In [36]:
set1,set2={10,20,30,40,50},{20,40,60}
In [37]:
#union
set3=set1|set2
set3
Out[37]:
{10, 20, 30, 40, 50, 60}
In [38]:
#intersection
set3=set1&set2
set3
Out[38]:
{20, 40}
In [39]:
#difference
set3=set1-set2
set3
Out[39]:
{10, 30, 50}
In [40]:
#symmetric difference
set3=set1^set2
set3
Out[40]:
{10, 30, 50, 60}
These operators are not really symbols but phrases. Each Python object is allocated required space in computer memory. Address of memory location is obtained by built-in id() function. Python variable is really reference name given to this location. More than one variables can refer to same location. Following identity operators tell us if id() values of both objects is same or different.
Operator | Description |
|---|---|
is | returns true if both operands point to the same object and false otherwise. |
is not | returns true if both operands don’t point to the same object and false otherwise. |
In [41]:
a=10
b=a
print (id(a), id(b))
a is b
1860398432 1860398432
Out[41]:
True
In [42]:
a=10
b=a*2
print (id(a), id(b))
a is b
1860398432 1860398752
Out[42]:
False
Any object in memory is represented in binary bits. The bitwise representation of object is manipulated by following operators. In following illustration, built-in bin() function is used to verify result of operations. The bin() function returns the binary equivalent of integer object. For example:
a=45 and bin(45) is 00101101
b=25 and bin(25) is 00011001
Following table lists the bitwise operators.
symbol | Operator | Description |
|---|---|---|
& | Binary AND | 0&0=0 0&1=0 1&0=0 1&1=1 |
| | Binary OR | 0|0=0 0|1=1 1|0=1 1|1=1 |
^ | Binary XOR | 0^0=0 0^1=1 1^0=1 1^1=0 |
~ | Binary Ones Complement | It is unary operator that flips bits. |
<< | Binary Left Shift | bits moved to left by specified places and adds trailing 0s |
>> | Binary Right Shift | bits moved to right by specified places and adds leading 0s |
In [43]:
a,b=45,25
bin(a),bin(b)
Out[43]:
('0b101101', '0b11001')
In [44]:
#binary and
c=a&b
c, bin(c)
Out[44]:
(9, '0b1001')
In [45]:
#binary or
c=a|b
c, bin(c)
Out[45]:
(61, '0b111101')
In [46]:
#binary xor
c=a^b
c, bin(c)
Out[46]:
(52, '0b110100')
In [47]:
#binary complement
c=~a
c, bin(c)
Out[47]:
(-46, '-0b101110')
In [48]:
#left shift
c=a<<2
c, bin(c)
Out[48]:
(180, '0b10110100')
In [49]:
#right shift
c=a>>2
c, bin(c)
Out[49]:
(11, '0b1011')
Just to verify bitwise & operation on a and b by using truth table for & operator
a = 45 = 00101101
b = 25 = 00011001
-----------------------
a&b = 00001001 = 9