Hey Everyone, I am Vikram Salunke and welcome to Python for InfoSec.
This is a part 4 and in this post we will see Operators.
Let's first look at the numbers.
In Python integers and floats can be represented. Let's look at the integer example

num1 = 2

print num1

ok, this is an integer.
And what is float? float is any number with decimal.

num2 = 4.2

print num2

ok, this is a float.

Integer and float

Assignment Operator

Let's look at the operators, first we are going to see assignment operator.

Assignment Operator


Assignment operator assigns the values of right side operand to the left side operand.
for example

num1 = 2

This is assignment operator.
2 has assigned to num1, so, num1 contains 2.
This is known as assignment operator, which we have seen earlier.

Arithmetic Operator

Now let's look at the Arithmetic Operators.
Addition, Subtraction, Multiplication, Division, Modules, Exponent etc. are known as the Arithmetic Operators.

Arithmetic Operators

Addition Operator

Now let's first look at the, Addition Operator

num1 = 2 + 2

Let's look at the num1

print num1

Ok, so addition operator add the values and store the result into the variable.

In this case 2 got added into 2 and it got stored into num1.

Subtraction Operator

Let's look at the subtraction operator

num2 = 4 - 2

print num2

So, it subtracts the value from right side operand from left side operand and store the result into the variable.

Multiplication Operator

Now let's look at the multiplication operator.

num3 = 4 * 2

print num3

It multiplies the value and store the result into the variable.

Division Operator

Let's look at the division operator

num4 = 4 / 2

print num4

It divides the left hand hand operand with right side operand.

Addition Subtraction Multiplication Division Operators

Modules Operator

Let's look the Modules operator

num5 = 8 % 2

print num5

It stores the remainder by dividing left side operand with right side operand.

Exponent Operator

Now let's look at the Exponent Operator

num6 = 2 ** 2

print num6

So it calculates the exponential power.

Modules and Exponent Operators

There are other operators also such as Relational, Logical, Bitwise Identity, Membership etc. I am not going to confuse you guys with too much information. So, we will see those operators when we will need them

If you want to join our in person class then please click here we are doing trainings in some upcoming InfoSec conferences.
And if you have any doubts, any questions then you can tweet me @vikramsalunke20
We are uploading daily new videos on YouTube click here to subscribe.
If you want to solve the exercises on this topic those are below. Solve the exercises and check your understandings. Thank you :)