0% found this document useful (0 votes)
9 views18 pages

Module 1 Sent

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views18 pages

Module 1 Sent

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Module-1 [Basics of Python]

• Introduction to Python
• Why Python
• Where Python is Used
• Algorithm
• Flowchart
• Elements of Python
- Keywords
- Identifiers
- Variables
• Python Data Types
• Python Operators
• Operator Precedence & Associativity
• Type Conversion in Python
• Python Comments
• Input and Output in Python
Python Data Types
• Data types specify the type of data that can be stored inside a variable
Python Data Types

• Everything is an object in Python programming .


• Data types are classes.
• Variables are instances(object) of these classes
Various Datatypes in Python
 Mutable [change after creation] data type in Python
- List
- Sets
- Dictionary
 Immutable[cannot change or we can delete] data type in Python
- Numbers
- Strings
- Tuples
String List Tuple Set Dictionary
Immutable Mutable Immutable Mutable Mutable

Ordered /Indexed Ordered Ordered /Indexed Unordered Unordered


/Indexed

Allows Duplicate members Allows Duplicate Allows Duplicate Doesn’t allow Duplicate Doesn’t allow Duplicate
members members members members

Empty String = “ “ Empty list = [ ] Empty tuple= ( ) Empty set = ( ) Empty dictionary ={ }

String with single element List with single item = Tuple with single item = Set with single item = Dictionary with single
=“ H “ [“Hello”] (“Hello”) (“Hello”) item = {“Hello” :1}

It can store data type It can store any data It can store any data type It can store data types Inside of dictionary [ key
string only type str , list , set , str , list , set , tuple , int (int, str , tuple) but not can be int , str and tuple
tuple , int and and (list , set and only ]but values can be of
dictionary dictionary dictionary ) any data type int ,
str ,list ,tuple ,set and
dictionary
Python Operators
• Python operators are used to perform operations on values and variables.
OPERATORS : Are the special symbols. Example:- + , * , /, etc.
OPERAND [x & y] : It is the value on which the operator is applied.
• Python operators are
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Identity Operators
- Membership Operators
Arithmetic Operators
Arithmetic operators are used to performing mathematical operations like
addition, subtraction, multiplication, and division.
Comparison Operators
Comparison or Relational operators compares the values.
 It either returns True or False.
Comparison Operators
Logical Operators
It performs Logical AND, Logical OR, and Logical NOT operations.
 It is used to combine conditional statements.
Bitwise Operators
Bitwise operators act on bits and perform the bit-by-bit operations. These are
used to operate on binary numbers.
Assignment Operators
Assignment operators are used to assign values to the variables.
Assignment Operators
Assignment Operators with Example
Identity Operators

The identity operators both are used to check if two values are located on the
same part of the memory.
Two variables that are equal do not imply that they are identical.
Membership Operators
 It is used to test whether a value or variable is in a sequence.
OPERATOR PRECEDENCE & ASSOCIATIVITY

Operator Precedence and Associativity, determine the priorities of the operator.

• Operator Precedence :- This is used in an expression with more than one operator with
different precedence to determine which operation to
perform first.

• Operator Associativity :- If an expression contains two or more operators with the same
precedence.
- It can be either be Left to Right or from Right to Left

• P – Parentheses
• E – Exponentiation
• M – Multiplication (Multiplication and division have the same precedence)
• D – Division
• A – Addition (Addition and subtraction have the same precedence)
• S – Subtraction
OPERATOR PRECEDENCE & ASSOCIATIVITY

You might also like