Contents

## data handling in python class 11 important questions

### Q 1. What are data types ? What are Python’s built-in core data types? (data handling in python)

ans. The real life data is of many types. So to represent various types of real-life data programming languages provide ways and facilities to handle these, which are known as data types.
Python’s built-in core data types belong to:

#### To read :- Data Handling in Python Class 11 notes

• Numbers (integer, floating-point, complex number, Booleans)
• String
• List
• Tuple
• Dictionary

### Q 2. Which data types of Python handle Numbers ?

ans. Python provides following data types to handle numbers
(i) Integers
(ii) Boolean
(iii) Floating-point numbers
(iv) Complex numbers

### Q 3 Why is Boolean considered a subtype of integer ?

ans. Boolean values True and False internally map to integers 1 and 0. That is, internally True is considered equal to 1 and False equal to 0 (zero). When 1 and 0 are converted to Boolean through bool() function, they return True and False. That is why Booleans are treated as a subtype of integers.

### Q 4. Identify the data types of the values given below :3, 3j, 13.0, ’13’, “13”, 2+0j, 13, [3,13,2], (3,13,2)

ans.
3 integer
3j complex number
13.0 Floating-point number
’13’ string
“13” string
2+0j complex number
13 integer
[3,13,2] List
(3,13,2) Tuple

### Q 5. What do you understand by term ‘immutable’?

ans. Immutable means unchangeable. In Python, immutable types are those whose values cannot be changed in place. Whenever one assigns a new value to a variable referring to immutable type, variable’s reference is changed and previous value is left unchanged. e.g.,

(1) x = 3

(2) x = 5

x ——-X——–> 3 } value 3 is untouched and
—————–> 5 } x is made to refer to new value.

### Q6. What will be the output of the following ?print (len(str(17//4)) )print (len(str(17/4)) )

ans. 1
3
because,

``````           (len(str(17//4)) )
= len(str(4))
= len('4')
= 1``````

and

`(len(str(17/4)) )= len(str(4.0))= len('4.0')= 3`

ans. (a) 3.0
(b) 1
(c) 2
(d) 3.5
(e) 3.0
(f) 2.0

ans.
10
True
True
False

ans.
(a) 17
(b) 17.0
(c) True
(d) True
(e) True

### Q 10. What will be the output of following code ? Why ?(i) 13 or len(13)(ii) len(13) or 13

ans.
(i) 13 because or evaluates first argument 13’s truth value, which is truetval and hence returns the results
as 13 without evaluating second argument.
(ii) error because when or evaluates fist argument len(13), Python give error as len() works on strings only.

### Q 11. What will be the output produced by these code statement ?(a) bool(int(‘0’))(b) bool(str(0))(c) bool(float(‘0.0’))(d) bool(str(0.0))

ans. (a) False (b) True (c) False (d) True

### GLOSSARY

#### Atom

Something that has a value.

#### Coercion

Implicit Type of Conversion.

#### Expression

Valid combination of operator and atoms.

#### Explicit Type conversion

Forced data type conversion by the user.

#### Immutable Type conversion

A type whose value is not changeable in place.

#### Implicit Type conversion

Automatic Internal conversion of data type (lower to higher type) by Python

#### Mutable Type

A type whose value is changeable in place.

#### Operator

Symbol/word that triggers an action or operation.

#### Type Casting

Explicit Type Conversion