Monday, February 11, 2019

Python Operator


What coding can do?
What coding can help?
How python help us in coding ?

Python Operator is one of those basic but "powerful" problem solving tools.
We may use it to do arithmetic operation like solving our daily Mathematics questions.
We can't deny how powerful is it when it combine with other operators like Assignment operators, Comparison operators, Logical operators, Identity operators, Membership operators and bitwise operator.

Assignment operators, we can guess what it does by its name. Simpy - it do assignment.
Wait a second! What is assignment ?
Remember = means assignment and == means equal in python.
Some  may scratch his or her head when it come to here.
Kind of confusing, huh?
Lets say we have a variable name box, and we put RM 10 into it.
Simply the equation will be as follows:
box = 10 (This is called assignment)

But, is box equal to 10 ? No! box is a container to keep the money.

Then what == do ?
We use == when we need to do comparison, which will be discussed in Comparison Operators.

If my mother give me 3 ringgit more, then i should have:
box = 10
box = box + 3 (total money I got at the moment) (= 13)
This equation is  kind of too long, it could be abbreviated as :
box += 3

Simply, x-=3 means x = x - 3
x * = 2 means x = x*2

You may explore more in the notes provided in the link below.

Okay! Now, we may continue to Comparison operator.
For instance, I would like to check if I got RM 10 in my box.
I use box == 10 (it return true if I got RM 10 else return false)
I had RM 13 now, so the equation will return false.
Obviously, box == 13 will return true.

It could be a super long story if I continue the other operator here.
You may explore more from the link below.
Please do try the humble and simple question provided in the notes as exercise.

Practise Makes Perfect!

Week3 - Python operator

No comments:

Post a Comment

Superior of partial fraction

What is complex fraction? Complex fraction is a fraction whereby its numerator or denominator or both consists of fractions. Partial frac...