Python Control Structures
Python Control Structures - Important Points
21. | Which of the following statements is used to sort a list in ascending order in Python? |
---|
A. list.sort()
B. sorted(list)
C. list.sort(reverse=True)
D. sorted(list, reverse=True)
View Answer Discuss Work SpaceAnswer: option b
Explanation:
22. | Which of the following statements is used to find the length of a string in Python? |
---|
A. string.length()
B. len(string)
C. length(string)
D. size(string)
View Answer Discuss Work SpaceAnswer: option b
Explanation:
23. | Which of the following statements is used to concatenate two strings in Python? |
---|
A. string1.add(string2)
B. string1.concat(string2)
C. string1 + string2
D. string1.join(string2)
View Answer Discuss Work SpaceAnswer: option c
Explanation:
24. | Which of the following statements is used to convert a string to uppercase in Python? |
---|
A. string.upper()
B. string.toUpper()
C. string.casefold()
D. string.capitalize()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
25. | Which of the following statements is used to remove an element from a list in Python? |
---|
A. list.remove(element)
B. list.pop(index)
C. list.delete(element)
D. list.splice(index, 1)
View Answer Discuss Work SpaceAnswer: option a
Explanation: