Professional Documents
Culture Documents
Worksheet 1
Worksheet 1
Worksheet 1
Holiday homework
Worksheet
Answers
For example, int, float, bool, string, unicode, tuple are immutable objects in
Python. In simple words, an immutable object can't be changed after it is
created. Lists, dictionaries and sets are mutable types.
7) Literals mean constants i.e., the data items that never change their value
during a program run. Python allows five types of literals:
(b) Octal Integer Literals:- A sequence of digits starting with 0 (digit zero)
is taken to be an octal integer.
For instance, decimal integer 8 will be written as 010 is octal integer. (810 =
108,) and decimal integer 12 will be written as 014 as octal integer (1210 =
148).
(b) else in a loop statement :- The else clause of a loop is executed when
the loop is terminating normally i.e., when its test-condition has gone false
for a while loop or when the for loop has executed for the last value in
sequence.
13) Iteration refers to repetition of a set of statements for a sequence of values
or as long as a condition is true.
14) In Python strings, each individual character is given a location number,
called index and this process is called indexing. Python allocates indices in
two directions:
For example :-
>>> 'Path Walla' [1:4]
>>> 'ath'
16)
(i) The lists are mutable sequences while strings are immutable.
(ii) In consecutive locations, a string stores the individual characters while
a list stores the references of its elements.
(iii) Strings store single type of elements - all characters while lists can
store elements belonging to different types.
18) The tuples and lists are different in following ways: