Page 289 - AI Ver 1.0 Class 9
P. 289
>>> 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'>
Literals
It is defined as any data stored in a variable. This data can be String literals are enclosed in single or double
quotes. For example,
"Hello"
‘Python’
• Numeric literals: They can be integer, float or complex. For example,
14
20.5
2+5j
• Boolean literals: They can be True or False. For example,
True
• Special literals: Only None is a special literal. It means something not yet created.
Punctuators
Punctuators are special symbols used in Python to organise statements and expressions. Most commonly used
punctuators in Python are:
‘ " # \ () {} [] @ , : . =
Operators
Operators are special symbols used to perform mathematical, logical and relational operations on variables
and values. The variables or values on which the operators work are called operands. Some commonly used
operators in Python are arithmetic operators, relational operators, logical operators and augmented assignment
operators.
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations on variables and values.
Introduction to Python 287

