51.What is the output of L[-2] if L = [1,2,3]?
L[-1] = 3, L[-2]=2, L[-3]=1
52.What is the output of L[1:] if L = [1,2,3]?
2, 3, Slicing fetches sections.
53. How will you compare two lists?
cmp(list1, list2) − Compares elements of both lists.
54. How will you get the length of a list?
len(list) − Gives the total length of the list.
55.How will you get the max valued item of a list?
max(list) − Returns item from the list with max value.
56. How will you get the min valued item of a list?
min(list) − Returns item from the list with min value.
57. How will you get the index of an object in a list?
list.index(obj) − Returns the lowest index in list that obj appears.
58.How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
59. How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
60. How will you remove an object from a list?
list.remove(obj) − Removes object obj from list.
L[-1] = 3, L[-2]=2, L[-3]=1
52.What is the output of L[1:] if L = [1,2,3]?
2, 3, Slicing fetches sections.
53. How will you compare two lists?
cmp(list1, list2) − Compares elements of both lists.
54. How will you get the length of a list?
len(list) − Gives the total length of the list.
55.How will you get the max valued item of a list?
max(list) − Returns item from the list with max value.
56. How will you get the min valued item of a list?
min(list) − Returns item from the list with min value.
57. How will you get the index of an object in a list?
list.index(obj) − Returns the lowest index in list that obj appears.
58.How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
59. How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
60. How will you remove an object from a list?
list.remove(obj) − Removes object obj from list.
No comments:
Post a Comment