Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Python Programming

- An Industry Perspective
Dr. Mani Madhukar
Ishan Vaid
Variable
Data Types

1.Numbers
2.String
3.List
4.Tuple
5.Dictionary
6.Boolean
Python Operators

Arithmetic Operators
➢ + Addition x + y
➢ – Subtraction x – y
➢ * Multiplication x * y
➢ / Division y / x
➢ % Modulus y % x
➢ ** Exponent Exponentiation x**b
➢ // Floor Division – Integer division rounded toward minus
infinity
Relational Operators

➢ == The condition becomes True, if the values of two operands are equal.
➢ != The condition becomes True, if the values of two operands are not equal.
➢ <> The condition becomes True, if values of two operands are not equal.(x<>y)
is true. This is similar to != operator.
➢ > The condition becomes True, if the value of left operand is greater than the
value of right operand.(x>y) is not true .
➢ < The condition becomes True, if the value of left operand is less than the value
of right operand.(x<y) is true.
➢ >= The condition becomes True, if the value of left operand is greater than or
equal to the value of right operand.
➢ <= The condition becomes True, if the value of left operand is less than or equal
to the value of right operand.
Logical Operators

➢ and Logical AND: True if both the operands are true x and y
➢ or Logical OR: True if either of the operands is true x or y
➢ not Logical NOT: True if operand is false not x

Bitwise operators

➢ & Bitwise AND x&y


➢ | Bitwise OR x|y
➢ ~ Bitwise NOT ~x
➢ ^ Bitwise XOR x^y
➢ >> Bitwise right shift x>>
➢ << Bitwise left shift x<<
Assignment operators

➢= x=y+z
➢ ^= ^=b a=a^b
➢ += a+=b a=a+b
➢ >>= a>>=b a=a>>b
➢ -= a-=b a=a-b
➢ <<= a <<= b a= a << b
➢ *= a*=b a=a*b
➢ /= a/=b a=a/b
➢ %= a%=b a=a%b
➢ //= a//=b a=a//b
➢ **= a**=b a=a**b
➢ &= a&=b a=a&b
➢ |= a|=b a=a|b
Identity operators

➢ is True if the operands are identical


➢ is not True if the operands are not identical

Membership operators

➢ in True if value is found in the sequence


➢ not in True if value is not found in the sequence
Type conversion

➢ int()
➢ float()
➢ str()
➢ tuple()
➢ set()
➢ list()
Conditional statement

➢ if
➢ if….else
➢ elif
➢ Nested if
Looping

➢ for − loops through a block of code a specified number of


times.
➢ while − loops through a block of code if and as long as a
specified condition is true.
Control Statements

➢ break statement
➢ continue statement
Manipulating Python Strings

➢ Creation Lower Case Strings


➢ Accessing ➢ Reversing
➢ Length ➢ Strip
➢ Finding ➢ Concatenation
➢ Count ➢ Join
➢ Slicing
➢ Split Strings
➢ Startswith / Endswith
➢ Repeat Strings
➢ Replacing

You might also like