# Notes And Questions NCERT Class 11 Computer Science Chapter 3 Data Handling

Please refer to Data Handling Class 11 Computer Science Notes and important questions below. The Class 11 Computer Science Chapter wise notes have been prepared based on the latest syllabus issued for the current academic year by CBSE. Students should revise these notes and go through important Class 11 Computer Science examination questions given below to obtain better marks in exams

## Data Handling Class 11 Computer Science Notes and Questions

The below Class 11 Data Handling notes have been designed by expert Computer Science teachers. These will help you a lot to understand all the important topics given in your NCERT Class 11 Computer Science textbook. Refer to Chapter 1 Data Handling Notes below which have been designed as per the latest syllabus issued by CBSE and will be very useful for upcoming examinations to help clear your concepts and get better marks in examinations.

3.1 Data Types in Python:
Python has Two data types –

1. Primitive Data Type (Numbers, String)
2. Collection Data Type (List, Tuple, Set, Dictionary)

Primitive Data Types:
a. Numbers:
Number data types store numeric values.
There are three numeric types in Python:

• int
• float
• complex

Example:
w = 1 # int
y = 2.8 # float
z = 1j # complex

• integer : There are two types of integers in python:
• int
• Boolean

• int: int or integer, is a whole number, positive or negative, without decimals. Example:

x = 1
y = 35656222554887711
z = -3255522

• Boolean: It has two values: True and False. True has the value 1 and False has the value 0.

Example:
>>>bool(0)
False
>>>bool(1)
True
>>>bool(‘ ‘)
False
>>>bool(-34)
True
>>>bool(34)
True

• float : float or “floating point number” is a number, positive or negative, containing one or more decimals. Float can also be scientific numbers with an “e” to indicate the power of 10.

Example:
x = 1.10
y = 1.0
z = -35.59
a = 35e3
b = 12E4
c = -87.7e100

• complex : Complex numbers are written with a “j” as the imaginary part.

Example:
x = 3+5j
y = 2+4j
z=x+y
print(z)
5+9j
z.real
5.0
>>>z.imag
9.0
Real and imaginary part of a number can be accessed through the attributes real and imag.

b. String: Sequence of characters represented in the quotation marks.

• Python allows for either pairs of single or double quotes. Example: ‘hello’ is the same as “hello” .
• Python does not have a character data type, a single character is simply a string with a length of 1.
• The python string store Unicode characters.
• Each character in a string has its own index.
• String is immutable data type means it can never change its value in place.

2. Collection Data Type:

• List
• Tuple
• Set
• Dictionary

3.2 MUTABLE & IMMUTABLE Data Type:

• Mutable Data Type: These are changeable. In the same memory address, new value can be stored. Example: List, Set, Dictionary
• Immutable Data Type: These are unchangeable. In the same memory address new value cannot be stored. Example: integer, float, Boolean, string and tuple.

3.3 Basic Operators in Python:
i. Arithmetic Operators
ii. Relational Operator
iii. Logical Operators
iv. Bitwise operators
v. Assignment Operators
vi. Other Special Operators
o Identity Operators
o Membership operators

i. Arithmetic Operators: To perform mathematical operations.

Example:
>>>x= -5
>>>x**2
>>> -25

ii. Relational Operators: Relational operators compare the values. It either returns True or False according to the condition.

iii. Logical operators: Logical operators perform Logical AND, Logical OR and Logical NOT operations.

Examples of Logical Operator:
The and operator: The and operator works in two ways:
a. Relational expressions as operands
b. numbers or strings or lists as operands

5>8 and
7>3 False
>>> (4==4) and (7==7)
True

b. numbers or strings or lists as operands: In an expression X and Y, if first operand has false value, then return first operand X as a result, otherwise returns Y.

>>>0 and 0
0 >>>0 and 6
0
>>>‘a’ and ‘n’
’n’
>>>6>9 and ‘c’+9>5 # and operator will test the second operand only if the first operand
False
# is true, otherwise ignores it, even if the second operand is wrong

The or operator: The or operator works in two ways:
a. Relational expressions as operands
b. numbers or strings or lists as operands

a. Relational expressions as operands:

5>8 or 7>3
True
>>> (4==4) or (7==7)
True

b. numbers or strings or lists as operands: In an expression X or Y, if first operand has true value, then return first operand X as a result, otherwise returns Y.

0 or 0
0
>>>0 or 6
6
>>>‘a’ or ‘n’
’a’
>>>6<9 or ‘c’+9>5 # or operator will test the second operand only if the first operand
True
# is false, otherwise ignores it, even if the second operand is wrong
The not operator:
>>>not 6
False
>>>not 0
True
>>>not -7
False
Chained Comparison Operators:
>>> 4<5>3 is equivalent to >>> 4<5 and 5>3
True True

iv. Bitwise operators:
Bitwise operators acts on bits and performs bit by bit operation.

Examples:
Let
a = 10
b = 4
print(a & b)
print(a | b)
print(~a)
print(a ^ b)
print(a >> 2)
print(a << 2)

Output:
0
14
-11
14
2
40

v. Assignment operators: Assignment operators are used to assign values to the variables.

vi. Other Special operators: There are some special type of operators like-
a. Identity operators- is and is not are 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 does not imply that they are identical.

Example:
Let
a1 = 3
b1 = 3
a2 = ‘PythonProgramming’
b2 = ‘PythonProgramming’
a3 = [1,2,3]
b3 = [1,2,3]
print(a1 is not b1)

print(a2 is b2) # Output is False, since lists are mutable.
print(a3 is b3)

Output:
False
True
False
Example:
>>>str1= “Hello”
>>>str2=input(“Enter a String :”)
Enter a String : Hello
>>>str1==str2 # compares values of string
True
>>>str1 is str2 # checks if two address refer to the same memory address
False

b. Membership operators- in and not in are the membership operators; used to test whether a value or variable is in a sequence.

Example:
Let
x = ‘Digital India’
y = {3:’a’,4:’b’}
print(‘D’ in x)
print(‘digital’ not in x)
print(‘Digital’ not in x)
print(3 in y)
print(‘b’ in y)

Output:
True
True
False
True
False

3.4 Operator Precedence and Associativity:

Operator Precedence:
It describes the order in which operations are performed when an expression is evaluated. Operators with higher precedence perform the operation first.

Operator Associativity: whenever two or more operators have the same precedence, then associativity defines the order of operations.