Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python code?
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]

What will be the output of the following Python code?
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]
a) Invalid syntax for slicing
b) [0,2]
c) (0,1)
d) (0,2)

Answer: c
Explanation: The method illustrated in the above piece of code is that of naming of slices.

Join The Discussion