CBSE Class 12 Informatics Practices
Question 114 of 167
Python Pandas — I — Question 4
Back to all questions(a)
Series([], dtype: int64)
The slice S[1:1] starts at index 1 and ends at index 1, but because the end index is exclusive, it does not include any elements, resulting in an empty Series.
(b)
pencils 20
dtype: int64
The slice S[0:1] starts at index 0 and ends at index 1, but because the end index is exclusive, it includes only one element i.e., the element at index 0.
(c)
pencils 20
notebooks 33
dtype: int64
The slice S[0:2] starts at index 0 and ends at index 1, hence, it includes two elements i.e., elements from index 0 and 1.
(d)
pencils 12
notebooks 12
scales 52
erasers 10
dtype: int64
The slice S[0:2] = 12 assigns the value 12 to indices 0 and 1 in Series S, directly modifying those elements. The updated Series is then printed.
(e)
Index(['pencils', 'notebooks', 'scales', 'erasers'], dtype = 'object')
[20 33 52 10]
The code print(S.index) displays the indices of Series S, while print(S.values) displays the values of Series.