step by step python(week2)

25
Step By Step Python By- Abhishek Jaiswal Via- www.letustweak.com Twitter- @jabhij

Upload: abhishek-jaiswal

Post on 13-Apr-2017

62 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Step by step python(week2)

Step By Step Python

By- Abhishek JaiswalVia- www.letustweak.comTwitter- @jabhij

Page 2: Step by step python(week2)

Week 2

Want a Recap..Of Week1

Page 3: Step by step python(week2)

Operators

Precedence

Conditionals

Demos / Quiz

Agenda

Page 4: Step by step python(week2)

Operators Arithmetic Relational / Comparison Logical / Boolean Membership Assignment Bitwise

Page 5: Step by step python(week2)

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)

Page 6: Step by step python(week2)

Explanation Board

Page 7: Step by step python(week2)

Explanation Board

Page 8: Step by step python(week2)

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)

Page 9: Step by step python(week2)

Explanation Board

Page 10: Step by step python(week2)

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

Page 11: Step by step python(week2)

Explanation Board

Page 12: Step by step python(week2)

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]

Page 13: Step by step python(week2)

Explanation Board

Page 14: Step by step python(week2)

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)

Page 15: Step by step python(week2)

Explanation Board

Page 16: Step by step python(week2)

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

Page 17: Step by step python(week2)

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.)

Page 18: Step by step python(week2)

Structureif expression :

statement (s). . .. . .

else:statement (s). . .

print (‘Outside if’)

(if else Statement)

Page 19: Step by step python(week2)

Explanation Board

Page 20: Step by step python(week2)

Quick Examples

Let’s have a look --

Page 21: Step by step python(week2)

WhatWe Have Learned..Today Operators Precedence Conditionals

Page 22: Step by step python(week2)

Q&A

Go, shoot your doubts.

Page 23: Step by step python(week2)

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

Page 24: Step by step python(week2)

Quote for the Week

“Be You,

Everyone else is already taken.”

Page 25: Step by step python(week2)

Thank You!