Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Python program that will create a list of ten tupples. Each tuple should consist of two random integer numbers between 1 and 20 (inclusive).

Write Python program that will create a list of ten tupples. Each tuple should consist of two random integer numbers between 1 and 20 (inclusive).

Your program should sort and display the list in three different ways. First it should sort according to the first element in each tuple, second time it should sort according to the second element and third time it should sort according to the sum of the two numbers. For example if the list is (for simplicity I 'm using a list of 3 tuples instead of 10 tuples)

[(2,5), (1,3),(4,2)]

the first sort should give [(1,3), (2,5), (4,2)]

the second sort should give [(4,2),(1,3),(2,5)]

and the third sort should result in [(1,3),(4,2),(2,5)]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

More Books

Students also viewed these Databases questions