PLS HELP ASAP! WILL GIVE BRAINLIEST!

Level 7 Questions
Create a program which:
- Gets the program to ask the user to type in 3 numbers
- The program must then display the 3 numbers back onto the screen in order (starting with the smallest)

Answer :

Zaxoosh

Answer:

# Python program to demonstrate sorting by user's  

# choice  

 

# function to return the second element of the  

# two elements passed as the parameter  

def sortSecond(val):  

   return val[1]  

 

# list1 to demonstrate the use of sorting  

# using using second key  

list1 = [(1, 2), (3, 3), (1, 1)]  

 

# sorts the array in ascending according to  

# second element  

list1.sort(key = sortSecond)  

print(list1)  

 

# sorts the array in descending according to  

# second element  

list1.sort(key = sortSecond, reverse = True)  

print(list1)

Other Questions