Q: Which of the following commands will create a list?
Solution: Execute in the shell to verify
Q: What is the output when we execute list(“hello”)?
Solution: Execute in the shell to verify.
Q: Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
Solution: Execute in the shell and verify.
Q: Suppose list1 is [2445,133,12454,123], what is max(list1)?
Solution: Max returns the maximum element in the list.
Q: Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?
Solution: Min returns the minimum element in the list.
Q: Suppose list1 is [1, 5, 9], what is sum(list1)?
Solution: Sum returns the sum of all elements in the list.
Q: To shuffle the list(say list1) what function do we use?
Solution: Execute in the shell to verify.
Q: Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
Solution: Slicing is allowed in lists just as in the case of strings.
Q: Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
Solution: -1 corresponds to the last index in the list.
Q: Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
Solution: Execute in the shell to verify.
You Have Score    | /10 |