Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started