Download - Step by step python(week2)
Step By Step Python
By- Abhishek JaiswalVia- www.letustweak.comTwitter- @jabhij
Week 2
Want a Recap..Of Week1
Operators
Precedence
Conditionals
Demos / Quiz
Agenda
Operators Arithmetic Relational / Comparison Logical / Boolean Membership Assignment Bitwise
Arithmetic OperatorsThe Arithmetic Operators are used to perform the fundamental mathematical operations or some other related operations.
Operator Meaning Structure
+ Addition / Unary Plus (a + b)- Subtraction / Unary minus (a - b)* Multiplication (a * b)% Modulus (a % b)/ Division (a / b)// Floor Division (a // b)** Exponent (a ** b)
Explanation Board
Explanation Board
Relational / Comparison OperatorsThe comparison operators are used to compare the values both side of the operators and performs specific operations based on them.
Operator Meaning Structure
> Greater than (a > b)
< Less than (a < b)
== Equal to (a == b)
!= Not Equal to (a != b)
>= Greater than or Equal to (a >= b)
<= Less than or Equal to (a <= b)
Explanation Board
Logical / Boolean OperatorsThe Logical Operators are used to perform operations based on Truth Table (Either True or False).
Operator Meaning Structure
and True if both the operands are true (a and b)
or True if either of the operands is true (a or b)not Complements the operand not a
Explanation Board
Membership Operators
The Membership Operators are used to check whether or not any particular element is in the group (List / Tuple / Dictionary).
Operator Meaning Structure
in Check to see if value is in the sequence
a in [a, b, c]
not in Check to see if value is not in the sequence
a not in [a, b, c]
Explanation Board
Assignment OperatorsThe Assignment Operators are used for assigning values to any variable while performing a certain operation.Operators Meaning Structure
= Assigns value from ROP to LOP a = b+= Adds ROP to the LOP and assigns result to LOP a = (a + b)
-= Sub ROP to the LOP and assigns result to LOP a = (a - b)
*= Mul ROP to the LOP and assigns result to LOP a = (a * b)
%= It takes mod using two operands and assigns result to LOP
a = (a % b)
/= Div ROP to the LOP and assigns result to LOP a = (a / b)
//= Div(Floor) ROP to the LOP and assigns result to LOP
a = (a // b)
Explanation Board
Precedence
Any IdeaOperator (Highest to Lowest) Description
() Parenthesis (grouping)f(args...), x[i:i], x[i], x.attr Function call, slicing, subscript, dot** Exponentiation+, -, ~ Unary Positive, Unary Negative, bitwise NOT*, /, % Multiplication, Division, Remainder+, - Addition, Subtraction<<, >> Shifts& Bitwise AND^ Bitwise XOR| Bitwise OR<, <=, >, >=, !=, ==, is, is not, in, not in Comparison, Identity, Membership not Boolean NOTand Boolean ANDor Boolean ORlambda Lambda Expressions
ConditionalsIn our day to day life we need to make decisions based on some situations / conditions etc.For example:If it’s not raining, I’ll go to the park.
In programming, the conditional statements are work in the same fashion. They are used to perform certain computations based on whether a condition is True or False.(In python make sure you have written True and False in capital letters.)
Structureif expression :
statement (s). . .. . .
else:statement (s). . .
print (‘Outside if’)
(if else Statement)
Explanation Board
Quick Examples
Let’s have a look --
WhatWe Have Learned..Today Operators Precedence Conditionals
Q&A
Go, shoot your doubts.
About meHe is a Passionate Geek and Student, who loves his hair and glasses more than anything, I guess. Geek | Blogger | Data Science Scholar | TechSavvy | Developer | Painter | Author | Trainer | Tech Evangelist | Philanthropist
Catch me @
Twitter- @jabhij Linkedin- jabhijSkype- jabhijWeb- www.letustweak.com
Tech Networks —
C# CornerCode ProjectMicrosoft ASP.NETLetUsTweakMVC4ALLDZone
Quote for the Week
“Be You,
Everyone else is already taken.”
Thank You!