Computer
GOOD MORNING
DEAR
Science
STUDENTS
Class -XI
Code No. 083
2024-25
CHAPTER: 4
DATA HANDLING IN
PYTHON
IN EXCEL 2013
TOPIC
• DATA TYPES
Learning Objectives: Success Criteria:
•List the types of Write a python
program to get user
data input either as
Sequence or Numerical
•Categorize the data type
Numeric and
Sequence data
types in Python
STARTER ACTIVITY:
•What is data? What are
the different types of
data available in the real
life?
Numeric Data Type Examples :
>>> num1= 12 >>> num2= -23 >>> num5= 1.5+2j
>>> type (num1) >>> type (num2) >>> type (num5)
<class ‘int’> < class ‘int’> < class ‘complex’>
>>> num3= 34.25 >>> num4= -54.678
>>> type(num3) >>> type(num4)
<class ‘float’> < class ‘float’>
They Are,
STRING DATA TYPE:
• In Python, a string is a sequence of characters enclosed within either single
quotes (' ') or double quotes (" ").
• It is an immutable data type, which means once a string is created, it cannot be
modified.
• However, it is possible to create a new string by concatenating two or more
strings.
• EXAMPLE:
>>> name=input(“enter your name”) or >>> name=“Robert”
>>> print(name)
LIST DATA TYPE:
• Lists are used to store multiple items in a single variable
• It is mutable, or changeable, ordered sequence of elements.
• Each element or value that is inside of a list is called an item.
• lists are defined by having values between square brackets[ ]
• EXAMPLE: >>> x=[“apple”, 23, 12.67, ”pen”,”pen”]
>>> print(x)
TUPLE DATA TYPE:
• A tuple is an ordered collection of elements, enclosed in parentheses(
).
• Tuples are immutable, which means that once a tuple is created, its
elements cannot be modified.
• Tuples can contain elements of different data types, such as integers,
strings, floats, or even other tuples.
• EXAMPLE: >>> cars=(“BMW”, “Tesla”, 2, “Suzuki”, ”Tesla”)
>>> print(cars)
STARTER TASK:
LEVEL-1 LEVEL-2 LEVEL-3
To calculate BMI To print personal To calculate
information like
(body mass average marks
Name, Father’s
index)of a Name, Class, and of 3 subjects for
person School Name of 5 5 students
students
SET DATA TYPE:
• A set is a data collection type used in Python for storing multiple items in a
single variable.
• Sets in Python are unordered and are not always consistent in the order they
get returned.
• Items in the set are immutable
• Duplicates are not permitted with Python data sets and will be removed
Example: set1={1,2,3,4} or set1={1,2,3,4,4}-removes the duplicate
print(set1)
DICTIONARY DATA TYPE:
• In Python, dictionaries are mutable data structures that allow you to
store key-value pairs.
• Dictionary can be created using the dict() constructor or curly braces'
{}’.
• Once you have created a dictionary, you can add, remove, or update
elements using the methods dict.
• EXAMPLE: >>> stationaries={‘pen’:2, ‘pencil’:3, ‘eraser’:5}
>>> print(stationaries)
Python Boolean:
• Boolean is a sub-data type of number’s integer data type.
• We declare it using the keyword ‘bool’.
• It has only two constant values which are ‘True’ or ‘False’.
• These values should start with a capital ‘T’ and a capital ‘F’ respectively. otherwise, the
interpreter gives an error.
• Boolean True values are denoted by non-zero, non-null, or 1.
• Boolean False values are denoted by 0.
>>> var1 = True >>>var2 = False
>>> type (var1) >>>type (var2)
<class ‘bool’> <class ‘bool’>
TOPIC
OPERATOR
PRECEDENCE
STARTER ACTIVITY:
•Write a python program to
display the values of
variables as numeric and
sequence data types
DEBUGGING:
• Debugging is the process of finding and
fixing errors or bugs in the source code of
any software.
• When software does not work as expected,
computer programmers study the code to
determine why any errors occurred.
TYPES OF ERRORS:
• Compile time errors
1. Syntax errors
2. Semantics errors
• Run time errors
• Logical errors