
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Data Science: Python Assignment Operators ... Data Science: Python Conditional Statements (if statement). If condition: x = x + 1 y = y + 5. In English:.
Typology: Lecture notes
1 / 32
This page cannot be seen from the preview
Don't miss anything!

























Addition
‐^
Subtraction
*^
Multiplication
/^
Division
%^
Modulus
**^
Exponentiation
//^
Floor
division
Operator Name
Example Same
As^ Outcome
=^
Assign
x^ =^8
X^ =^8
8
+=^
Add^ and
Assign
x^ +=^8
x^ =^ x^ +
8
16
‐=^
Subtract
and^ Assign
x ‐=^8
x^ =^ x^ ‐^
8
0
*=^
Multiply
and^ Assign
x *=^8
x^ =^ x^ *
8
64
/=^
Divide
and^ assign
x^ /=^8
x^ =^ x^ / 8
1
%=^
Mod^ and
Assign
x^ %=^8
x^ = x^ %^8
0
//=^
Floor^ Divide
and^ Assign x
//=^8
x^ =^ x^ //
8
1
**=^
Exponent
and^ Assign
x^ **=
8 x^ =^ x^ **^
8 16777216
Example
==^
Equal
x^ ==
y
!=^
Not
equal
x^ !=
y
^
Greater
than
x^ >^ y
<^
Less
than
x^ <^ y
=^
Greater
than
or^ equal
to x
=^
y
<=^
Less
than
or^ equal
to^
x^ <=
y
Example
in^
Returns
True
if^ a
sequence
with
the
specified
value
is^ present
in^ the
object
x^ in y
not in^
Returns
True
if^ a
sequence
with
the
specified
value
is^ not
present
in^ the
object
x
not
in^ y
Example
in^
Returns
True
if^ a
sequence
with
the
specified
value
is^ present
in^ the
object
x^ in y
not in^
Returns
True
if^ a
sequence
with
the
specified
value
is^ not
present
in^ the
object
x
not
in^ y
Example
and
Returns
True
if^ both
statements
are
true
x^ >^2
and
x^ <
or^
Returns
True
if^ one
of^ the
statements
is^ true
x^ >^2
or^ x
not
Reverse
the
result,
returns
False
if^ the
result
is^ true
not(x
^ 2and
x^ <
if^ condition:x =^ x
y^ =^ y^ +^
elif:print
(“error”) print
(“good
bye”)
In^ English:If^ this
is^ true
then
do
{^ x^ =
x^ +
y^ =^ x^ +^
} Else
if^ this
is^ true {^ print
a^ message print
good
bye
}
In^ English:If^ this
is^ false
then
do
{^ x^ =
x^ +
y^ =^
x^ +^
} Else
if^ this
is^ false {^ print
a^ message print
good
bye
}