Page 288 - AI Ver 1.0 Class 9
P. 288
• Numbers: Data with a numeric value falls into this category. It can be integer, float and complex. Python will
automatically convert a number from one type to another if needed. Following are some number types:
✶ Integer: Integers are whole numbers (+ve, -ve or 0) with no fractions or decimal value. Its length is dependent
on the available memory. For example, 10, 124, 4567, 7812568751.
✶ Float: It is a real number with floating point representation. For example, 15.5 and 12.0. It can also be represented
using the exponent notation E. For example, 1E5 is 100000.
✶ Complex: It is made up of a real number and an imaginary number. For example, 3+2i where 3 is a real number
and 2i is an imaginary number.
• None: This is a special data type with NULL or nothing/no value. It does not mean 0, False or empty. It is
represented by None.
• Sequence: It is a collection of data stored under a common name. Each value is referred by its index number. It
can be mutable or non-mutable. There are three types of data as sequence in Python:
✶ String: It is a sequence of UNICODE characters enclosed in single or double quotes. Multi-line strings can be
created using triple quotes (single or double). Its length is dependent on the available memory. It can also be
empty where we have just empty quotes with no value. For example,
" "
"Hello"
‘Python’
"I love ‘Python’"
‘‘‘It is
an interesting
Language’’’
✶ Lists: It is a sequence of heterogeneous values arranged as elements and are referred by an index number. These
values are separated by comma and are enclosed in square brackets[ ]. They are mutable data types as the values
of these data types can be changed by the user after creation. For example,
list_of_names=["Amit","Shweta","Peter","Zoya"]
Marks=[89,92,93,78,89]
class9=[101,"Neha",89.5,102,"Shushil",92]
✶ Tuples: It is a sequence of heterogeneous values arranged as elements and are referred by an index
number. These values are separated by comma and are enclosed in circular brackets ( ). They are immutable
as the values of these data types cannot be changed by the user after creation.
• Boolean: It is a data type with two built-in values: True or False. It is used in logical evaluation. A True value
represents 1 while a False represents 0.
Data Type Conversion
Data of one type can be converted into another type by using type conversion built-in functions like int(),
float(), str(), etc. The process of converting value of one data type to another is called type conversion or
type casting. For example,
>>> float(12)
12.0
>>> int(15.5)
15
286 Touchpad Artificial Intelligence-IX

