Write a Python program that performs the following task:

ICSE Class 10 Robotics & AI PYQ · 2027 Specimen · Section B

8(iii)Written · 2027 · Section B · 2027 Specimen

Write a Python program that performs the following task:

1. Create a tuple having elements (50,60,70,80,90).

2. Convert the above tuple to list.

3. Sort all the elements in descending order.

4. Remove the element 80 from the above list and print the list.

5. Sort the above in ascending order.

6. Convert the final list to tuple.

7. Print the final tuple.

Show SolutionHide Solution↓
t = (50, 60, 70, 80, 90)

l = list(t)

l.sort(reverse=True)

l.remove(80)
print(l)

l.sort()

ft = tuple(l)
print(ft)
[90, 70, 60, 50]
(50, 60, 70, 90)

← Previous question

Browse the free Robotics & AI sample bank