The fact that elements of a list need not be homogeneous makes them highly adaptable and powerful data structure in Python. Python lists are containers that can store an ordered list of values of same or different data types together in a single variable. True Type A : Short Answer Questions/Conceptual Questions Question 1ĭiscuss the utility and significance of Lists in Python, briefly. The del statement can work similar to the pop( ) function. The del statement can only delete list slices and not single elements from a list. The insert( ) can add an element in the middle of a list. The append( ) can add an element in the middle of a list. The extend( ) adds a single element to a list. To sort a list, sort( ) and sorted( ), both can be used. The pop( ) and remove( ) are similar functions.Ī = and A = list( ) will produce the same result. The list( ) and copy( ) are the similar functions. The sorted() function sorts a list and returns another list. The sort() function sorts a list and makes changes in the list. The extend() function can append a list elements to a list. The pop() function is used to delete element to remove an element from designated index in a list. The insert() function is used to insert element at a designated position in a list. To delete a list slice from a list, del statement is used Question 7Ī nested list contains another list as its member. To check if an element is in list, in operator is used. The + operator adds one list to the end another list. To create an empty list, function list() can used. Lists are mutable data types and thus their values can be changed. Which of the following can copy a list to another list? Which of the following searches for an element in a list and returns its index? Which of the following can delete an element from a list, if its value is given? Which of the following can delete an element from a list if the index of the element is given? Which of the following will always return a list? Which of the following can add a list of elements to a list? Which of the following can add only one value to a list? Which of the following is a standard Python library function and not an exclusively list function? ![]() What is the output when we execute list("hello")? Which of the following commands will create a list? ![]() Out of the following, what is correct syntax to copy one list into another? To find the last element of list namely 'smiles' in Python. ![]() Which of the following will return the last element of a list L with 5 elements? Which of the following will create an empty list?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |