COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What is the output of [ used on a list consisting of four character vectors, ls? For instance, ls[1]
|
A factor
|
|
A data frame
|
|
A character vector
|
|
A new, smaller list
|
Explanation:
Detailed explanation-1: -The sort() method lets you sort a list in ascending or descending order. It takes two keyword-only arguments: key and reverse . reverse determines if the list is sorted in ascending or descending order.
Detailed explanation-2: -The list() function creates a list object. A list object is a collection which is ordered and changeable.
Detailed explanation-3: -25 is the output. list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is a list that consists 1 to 10 numbers within it.
Detailed explanation-4: -To sort list items in descending order, you need to use the optional reverse parameter with the sort() method, and set its value to True .
There is 1 question to complete.