Write Program Creates Tuple Numbers Positive Negative Make New Tuple Positive Values Tupl Q37055950

Write a program that creates a tuple of numbers(both positiveand negative). Make a new tuple that has only positive values fromthis tuple and sorts it in descending order.

Tup = (-10, 1, 2, -9, 3, 4, -8, 5, 6)

Program run:
Original Tuple : (-10, 1, 2, -9, 3, 4, -8, 5, 6)
New Tuple with Positive numbers : (1, 2, 3, 4, 5, 6)


Solution


Codesnap:

t.py- D:/Chegg/Python/tuple_example/t.py (3.6.4) File Edit Format Run Options Window Help Tup= (-10, 1, 2, -9, 3, 4, -8, 5, 6

Tup = (-10, 1, 2, -9, 3, 4, -8, 5, 6)
print(“Tuple in Desendering Order”)
print(tuple(sorted(Tup,reverse=True)))
new=list(Tup)
new_list=[]
for i

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.