SlideShare a Scribd company logo
Data Handing in Python
Class 11
Chapter- 7
Introduction
• In this chapter we will learn data
types, variables, operators and
expression in detail.
• Python has a predefined set of data types
to handle the data in a program.
• We can store any type of data in Python.
DATA TYPES
• Data can be of any type like- character, integer, real,
string.
• Anything enclosed in “ “ is considered as string in
Python.
• Any whole value is an integer value.
• Any value with fraction part is a real value.
• True or False value specifies boolean value.
• Python supports following core data types-
I. Numbers
II. String
III. List
IV. Tuple
V. Dictionar
y
(int like10, 5) (float like 3.5, 302.24) (complex like
3+5i) (like “pankaj”, ‘pankaj’, ‘a’, “a” )
like [3,4,5,”pankaj”] its elements are
Mutable. like(3,4,5,”pankaj”) its elements are
immutable.
like {‘a’:1, ‘e’:2, ‘I’:3, ‘o’:4, ‘u’:5} where a,e,i,o,u
are keys
and 1,2,3,4,5 are their values.
CORE DATA TYPES
Graphical
View
CORE
DATA TYPE
Numbers
Integer
Boolean
Floating
Point
Complex
None Sequences
String Tuple List
Mappings
Dictionary
Mutable and Immutable
Types
• In Python, Data Objects are categorized in two
types-
• Mutable (Changeable)
• Immutable (Non-Changeable)
Look at following statements carefully-
p = 10
q = p they will represent 10, 10, 10
r = 10
Now, try to change the
values- p = 17 did the values actually
change?
r = 7
q =9
Answer is
NO.
Because here values are objects and p, q, r are their reference
name. To understand it, lets see the next slide.
Variables and Values
An important fact to know is-
– In Python, values are actually objects.
– And their variable names are actually their reference
names.
Suppose we assign 10 to a variable
A. A = 10
Here, value 10 is an object and A is
its reference name.
10
Reference
variable
Object
Variables and Values
If we assign 10 to a variable
B, B will refer to same object.
Here, we have two
variables, but with same
location.
Now, if we change value of B
like B=20
Then a new object will be created
with a new location 20 and this
object will be referenced by B.
10
10
20
Referenc
e
variable
Object
Mutable and Immutable
Types
Following data types comes under mutable
and immutable types-
• Mutable (Changeable)
– lists, dictionaries and sets.
• Immutable (Non-Changeable)
– integers, floats, Booleans, strings and tuples.
Variable
Internals
The Type of an Object
• Pay attention to the following command-
here 4 is an object and its class is int
here a is referring to the object
which is of int class.
Variable
Internals
The Value of an Object
• Pay attention to the following command-
here value output is coming via
print()
The ID of an Object
• Pay attention to the following command-
Here value 4 and variable a
are showing same id which means 4
is an object being referenced by a
that’s why they are keeping same id.
Operators
• The symbols that shows a special behavior
or action when applied to operands are
called operators. For ex- + , - , > , < etc.
• Python supports following operators-
I. Arithmetic Operator
II. Relation Operator
III. Identity Operators
IV. Logical Operators
V. Bitwise Operators
VI. Membership Operators
Arithmetic Operators
• Python has following binary arithmetic
operator -
• For addition +
• For subtraction –
• For multiplication
*
• For division /
• For
quotient //
• For remnant
%
• For exponent
**
for ex- 2+3 will result in to
5 for ex- 2-3 will result in
to -1 for ex- 2*3 will result
in to 6 its result comes in
fraction.
for ex- 13/2 will result in
to 6.5
its result comes as a whole
number for ex- 13/2 will result
into 6.
its result comes as a whole
remnant number.For ex-13/2will
Assignment Operators and
shorthand
• Python has following assignment operator and
shorthand -
• = a=10 , 10 will be assigned to a.
• += a+=5 is equal to a=a+5.
• -= a-=5 is equal to a=a-5.
• *= a*=5 is equal to a=a*5.
• /= a/=5 is equal to a=a/5.
• //= a//=5 is equal to a=a//5.
• %= a%=5 is equal to a=a%5.
• **= a**=5 is equal to a=a**5.
Relational Operators
• Python uses Relational operators to check for
equality. These results into true or false. Relational
Operator are of following types-
• < Less Than like a<b
• > Greater Than like a>b
• <= Less Than and Equal to like
a<=b
• >= Greater Than and Equal to like
a>=b
• == Equal to like
a==b
• != not Equal to like a!=b
Identity Operators
Identity operator is also used to check for equality.
These expression also results into True or False. Identity
Operators are of following types-
• “is”
operator
• “is not”
operator
if a=5 and b=5 then a is b will
come to True
if a=5 and b=5 then a is not b will
come to False
• Relational Operator ( == ) and Identity operator (is)
differs
in case of strings that we will see later.
Logical Operators
• Python has two binary logical operators -
• or operator
» if a = True and b = False then a or b
will return
True.
• and operator
» If a = True and b = False then a and
b will return
False.
• Python has one Unary logical operator –
• not operator
• if a = True then not a will return False.
Operator Associativity
• In Python, if an expression or statement
consists of multiple or more than one
operator then operator associativity will be
followed from left-to- right.
• In above given expression, first 7*8 will be calculated as 56, then
56 will be divided by 5 and will result into 11.2, then 11.2 again
divided by 2 and will result into 5.0.
*Only in case of **, associativity will be followed
from right-to-left.
Above given example will be calculated as 3**(3**2).
Expressions
• Python has following types of expression -
• Arithmetic Expressions like a+b, 5-4 etc.
• Relational Expressions like a>b, a==b etc.
• Logical Expressions like a>b and a>c , a or b
etc.
• String Expressions like “Pankaj” + “Kumar” etc.
Type
Casting
• As we know, in Python, an expression may be consists
of mixed datatypes. In such cases, python changes
data types of operands internally. This process of
internal data type conversion is called implicit
type conversion.
• One other option is explicit type conversion which is like-
<datatype>
(identifier) For ex-
a=“4”
b=int(a)
Another ex-
If a=5 and b=10.5 then we can convert
a to float. Like d=float(a)
In python, following are the data conversion
functions-
Working with math Module of
Python
• Python provides math module to work for all
mathematical works. We need to write following
statement in our program-
import math
output of this program will be 5.0
To get to know functions of a module, give following command-
>>>dir (math)
Taking Input in Python
• In Python, input () function is used to take input which takes input
in the form of string. Then it will be type casted as per
requirement. For ex- to calculate volume of a cylinder,
program will be as-
• Its output will be
as-
DEBUGGING
 Debugging in Python is the process of identifying and resolving
issues or errors in the code.
 It involves analyzing the code to find the root cause of unexpected
behavior, exceptions, or incorrect output.
 The primary goal of debugging is to locate and fix bugs, ensuring
that the code works as intended and produces the correct results.
Types of Built-in Exceptions
Python's built-in exceptions cover a wide range of error conditions.
Here are some of the common categories and specific exceptions:
Arithmetic Errors: These include OverflowError, ZeroDivisionError,
and FloatingPointError, which occur during arithmetic operations.
Attribute Errors: AttributeError is raised when attribute reference or
assignment fails.
File Errors: FileNotFoundError is raised when a file or directory is
requested but doesn’t exist.
Index Errors: IndexError is raised when a sequence subscript is out of
range.
Key Errors: KeyError is raised when a dictionary key is not found.
Name Errors: NameError is raised when a local or global name is not
found.
Syntax Errors: SyntaxError is raised when the parser encounters a
syntax error.
Type Errors: TypeError is raised when an operation or function is
applied to an object of inappropriate type.
Thank you
Please follow us on our blog-
www.pythontrends.wordpress.c
om
Ad

Recommended

chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
Jahnavi113937
 
Operators in Python Arithmetic Operators
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
Python programming language introduction unit
Python programming language introduction unit
michaelaaron25322
 
unit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
chapter-1-review-of-python-basics-copy.pdf
chapter-1-review-of-python-basics-copy.pdf
SangeethManojKumar
 
modul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
Python revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Lecture 1 .
Lecture 1 .
SwatiHans10
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
python presentation.pptx
python presentation.pptx
NightTune44
 
An overview on python commands for solving the problems
An overview on python commands for solving the problems
Ravikiran708913
 
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
GiancarlosGumatay
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
UNIT II_python Programming_aditya College
UNIT II_python Programming_aditya College
Ramanamurthy Banda
 
Programming Basics.pptx
Programming Basics.pptx
mahendranaik18
 
Python Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptx
malekaanjum1
 
Python.pptx
Python.pptx
Ankita Shirke
 
Java ppt2
Java ppt2
Gurpreet singh
 
Learn Java Part 2
Learn Java Part 2
Gurpreet singh
 
Java ppt2
Java ppt2
nikhilsh66131
 
Java ppt2
Java ppt2
nikhilsh66131
 
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PraveenaFppt
 
data handling revision.pptx
data handling revision.pptx
DeepaRavi21
 
Python basics
Python basics
TIB Academy
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Py-Slides-2 (1).ppt
Py-Slides-2 (1).ppt
KalaiVani395886
 
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Rajdeep Bavaliya
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 

More Related Content

Similar to Grade XI - Computer science Data Handling in Python (20)

Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
python presentation.pptx
python presentation.pptx
NightTune44
 
An overview on python commands for solving the problems
An overview on python commands for solving the problems
Ravikiran708913
 
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
GiancarlosGumatay
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
UNIT II_python Programming_aditya College
UNIT II_python Programming_aditya College
Ramanamurthy Banda
 
Programming Basics.pptx
Programming Basics.pptx
mahendranaik18
 
Python Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptx
malekaanjum1
 
Python.pptx
Python.pptx
Ankita Shirke
 
Java ppt2
Java ppt2
Gurpreet singh
 
Learn Java Part 2
Learn Java Part 2
Gurpreet singh
 
Java ppt2
Java ppt2
nikhilsh66131
 
Java ppt2
Java ppt2
nikhilsh66131
 
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PraveenaFppt
 
data handling revision.pptx
data handling revision.pptx
DeepaRavi21
 
Python basics
Python basics
TIB Academy
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Py-Slides-2 (1).ppt
Py-Slides-2 (1).ppt
KalaiVani395886
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
python presentation.pptx
python presentation.pptx
NightTune44
 
An overview on python commands for solving the problems
An overview on python commands for solving the problems
Ravikiran708913
 
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
GiancarlosGumatay
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
UNIT II_python Programming_aditya College
UNIT II_python Programming_aditya College
Ramanamurthy Banda
 
Programming Basics.pptx
Programming Basics.pptx
mahendranaik18
 
Python Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PraveenaFppt
 
data handling revision.pptx
data handling revision.pptx
DeepaRavi21
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 

Recently uploaded (20)

Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Rajdeep Bavaliya
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Paper 106 | Ambition and Corruption: A Comparative Analysis of ‘The Great Gat...
Rajdeep Bavaliya
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Ad

Grade XI - Computer science Data Handling in Python

  • 1. Data Handing in Python Class 11 Chapter- 7
  • 2. Introduction • In this chapter we will learn data types, variables, operators and expression in detail. • Python has a predefined set of data types to handle the data in a program. • We can store any type of data in Python.
  • 3. DATA TYPES • Data can be of any type like- character, integer, real, string. • Anything enclosed in “ “ is considered as string in Python. • Any whole value is an integer value. • Any value with fraction part is a real value. • True or False value specifies boolean value. • Python supports following core data types- I. Numbers II. String III. List IV. Tuple V. Dictionar y (int like10, 5) (float like 3.5, 302.24) (complex like 3+5i) (like “pankaj”, ‘pankaj’, ‘a’, “a” ) like [3,4,5,”pankaj”] its elements are Mutable. like(3,4,5,”pankaj”) its elements are immutable. like {‘a’:1, ‘e’:2, ‘I’:3, ‘o’:4, ‘u’:5} where a,e,i,o,u are keys and 1,2,3,4,5 are their values.
  • 4. CORE DATA TYPES Graphical View CORE DATA TYPE Numbers Integer Boolean Floating Point Complex None Sequences String Tuple List Mappings Dictionary
  • 5. Mutable and Immutable Types • In Python, Data Objects are categorized in two types- • Mutable (Changeable) • Immutable (Non-Changeable) Look at following statements carefully- p = 10 q = p they will represent 10, 10, 10 r = 10 Now, try to change the values- p = 17 did the values actually change? r = 7 q =9 Answer is NO. Because here values are objects and p, q, r are their reference name. To understand it, lets see the next slide.
  • 6. Variables and Values An important fact to know is- – In Python, values are actually objects. – And their variable names are actually their reference names. Suppose we assign 10 to a variable A. A = 10 Here, value 10 is an object and A is its reference name. 10 Reference variable Object
  • 7. Variables and Values If we assign 10 to a variable B, B will refer to same object. Here, we have two variables, but with same location. Now, if we change value of B like B=20 Then a new object will be created with a new location 20 and this object will be referenced by B. 10 10 20 Referenc e variable Object
  • 8. Mutable and Immutable Types Following data types comes under mutable and immutable types- • Mutable (Changeable) – lists, dictionaries and sets. • Immutable (Non-Changeable) – integers, floats, Booleans, strings and tuples.
  • 9. Variable Internals The Type of an Object • Pay attention to the following command- here 4 is an object and its class is int here a is referring to the object which is of int class.
  • 10. Variable Internals The Value of an Object • Pay attention to the following command- here value output is coming via print() The ID of an Object • Pay attention to the following command- Here value 4 and variable a are showing same id which means 4 is an object being referenced by a that’s why they are keeping same id.
  • 11. Operators • The symbols that shows a special behavior or action when applied to operands are called operators. For ex- + , - , > , < etc. • Python supports following operators- I. Arithmetic Operator II. Relation Operator III. Identity Operators IV. Logical Operators V. Bitwise Operators VI. Membership Operators
  • 12. Arithmetic Operators • Python has following binary arithmetic operator - • For addition + • For subtraction – • For multiplication * • For division / • For quotient // • For remnant % • For exponent ** for ex- 2+3 will result in to 5 for ex- 2-3 will result in to -1 for ex- 2*3 will result in to 6 its result comes in fraction. for ex- 13/2 will result in to 6.5 its result comes as a whole number for ex- 13/2 will result into 6. its result comes as a whole remnant number.For ex-13/2will
  • 13. Assignment Operators and shorthand • Python has following assignment operator and shorthand - • = a=10 , 10 will be assigned to a. • += a+=5 is equal to a=a+5. • -= a-=5 is equal to a=a-5. • *= a*=5 is equal to a=a*5. • /= a/=5 is equal to a=a/5. • //= a//=5 is equal to a=a//5. • %= a%=5 is equal to a=a%5. • **= a**=5 is equal to a=a**5.
  • 14. Relational Operators • Python uses Relational operators to check for equality. These results into true or false. Relational Operator are of following types- • < Less Than like a<b • > Greater Than like a>b • <= Less Than and Equal to like a<=b • >= Greater Than and Equal to like a>=b • == Equal to like a==b • != not Equal to like a!=b
  • 15. Identity Operators Identity operator is also used to check for equality. These expression also results into True or False. Identity Operators are of following types- • “is” operator • “is not” operator if a=5 and b=5 then a is b will come to True if a=5 and b=5 then a is not b will come to False • Relational Operator ( == ) and Identity operator (is) differs in case of strings that we will see later.
  • 16. Logical Operators • Python has two binary logical operators - • or operator » if a = True and b = False then a or b will return True. • and operator » If a = True and b = False then a and b will return False. • Python has one Unary logical operator – • not operator • if a = True then not a will return False.
  • 17. Operator Associativity • In Python, if an expression or statement consists of multiple or more than one operator then operator associativity will be followed from left-to- right. • In above given expression, first 7*8 will be calculated as 56, then 56 will be divided by 5 and will result into 11.2, then 11.2 again divided by 2 and will result into 5.0. *Only in case of **, associativity will be followed from right-to-left. Above given example will be calculated as 3**(3**2).
  • 18. Expressions • Python has following types of expression - • Arithmetic Expressions like a+b, 5-4 etc. • Relational Expressions like a>b, a==b etc. • Logical Expressions like a>b and a>c , a or b etc. • String Expressions like “Pankaj” + “Kumar” etc.
  • 19. Type Casting • As we know, in Python, an expression may be consists of mixed datatypes. In such cases, python changes data types of operands internally. This process of internal data type conversion is called implicit type conversion. • One other option is explicit type conversion which is like- <datatype> (identifier) For ex- a=“4” b=int(a) Another ex- If a=5 and b=10.5 then we can convert a to float. Like d=float(a) In python, following are the data conversion functions-
  • 20. Working with math Module of Python • Python provides math module to work for all mathematical works. We need to write following statement in our program- import math output of this program will be 5.0 To get to know functions of a module, give following command- >>>dir (math)
  • 21. Taking Input in Python • In Python, input () function is used to take input which takes input in the form of string. Then it will be type casted as per requirement. For ex- to calculate volume of a cylinder, program will be as- • Its output will be as-
  • 22. DEBUGGING  Debugging in Python is the process of identifying and resolving issues or errors in the code.  It involves analyzing the code to find the root cause of unexpected behavior, exceptions, or incorrect output.  The primary goal of debugging is to locate and fix bugs, ensuring that the code works as intended and produces the correct results.
  • 23. Types of Built-in Exceptions Python's built-in exceptions cover a wide range of error conditions. Here are some of the common categories and specific exceptions: Arithmetic Errors: These include OverflowError, ZeroDivisionError, and FloatingPointError, which occur during arithmetic operations. Attribute Errors: AttributeError is raised when attribute reference or assignment fails. File Errors: FileNotFoundError is raised when a file or directory is requested but doesn’t exist. Index Errors: IndexError is raised when a sequence subscript is out of range. Key Errors: KeyError is raised when a dictionary key is not found. Name Errors: NameError is raised when a local or global name is not found. Syntax Errors: SyntaxError is raised when the parser encounters a syntax error. Type Errors: TypeError is raised when an operation or function is applied to an object of inappropriate type.
  • 24. Thank you Please follow us on our blog- www.pythontrends.wordpress.c om