Page 103 - Information_Practice_Fliipbook_Class11
P. 103
Common Errors
● Missing quotation marks for strings
print(India) # string value not enclosed in quotation marks
● Not using the same quotation marks before and at the end of the string
print("India')
print('India")
# the string not enclosed within same type of quotation marks
● Copying a string from a word processor, for example,
>>> print('India')
SyntaxError: invalid character ''' (U+2018)
Also, observe the following,
>>> ord("'")
39
>>> ord("'")
8217
>>> ord("'")
8216
● Not using correct brackets for data types
myList = (1,2,5,9)
# The programmer wanted to create a list, but produced a tuple.
Let's Summarise
Ø A data type denotes a set of specific types of values. For example, the data type int includes negative and
non-negative integers.
Ø A numeric data type can store only numbers or numeric values on which arithmetic operations can be
performed.
Ø Numeric data type may be: int, float, and complex.
Ø bool or Boolean data type consists of two possible values: True and False.
Ø type() is used to get the data type of an object.
Ø A Python sequence is an ordered collection of items. Each item in a sequence is indexed by an integer.
Ø Strings (str), lists (list), and tuples (tuple) are examples of sequence types.
Ø A string is a sequence of characters enclosed in single (') or double (") quotation marks.
Ø A string enclosed between single or double quote marks is usually restricted to one line, but a long string may
be continued on the next line by terminating the line with a backslash character. For example,
>>> 'Hello',\
... How are you?'
'Hello,How are you?'
Ø A list is a sequence of objects (possibly heterogeneous) enclosed in square brackets: [].
Ø A tuple is a sequence of objects (possibly heterogeneous) enclosed in parenthesis ().
Ø A set is an unordered and unindexed collection of data items separated by a comma enclosed in curly
brackets {}.
Data Types and Operators 89

