menu

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)

Discuss Work Space

Answer: option b

Explanation:

The sorted() function is used to sort a list in ascending order in Python.

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)

Discuss Work Space

Answer: option b

Explanation:

The len() function is used to find the length of a string in Python.

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)

Discuss Work Space

Answer: option c

Explanation:

The + operator is used to concatenate two strings in Python.

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()

Discuss Work Space

Answer: option a

Explanation:

The upper() method is used to convert a string to uppercase in Python.

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)

Discuss Work Space

Answer: option a

Explanation:

The remove() method is used to remove an element from a list in Python.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now