Page 301 - Artificial Intellegence_v2.0_Class_9
P. 301
"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
>>> str(12)
'12'
>>> int(True)
1
>>> bool(0)
False
You can get the data type of any object by using type( ) function. For example,
>>> type(10)
<class 'int'>
>>> type("abc")
<class 'str'>
>>> type(14.5)
<class 'float'>
Introduction to Python 299

