Problems on Python Sorting

Problems on Python Sorting

Varanasi Software Junction: Sorting of Python Lists


You can consult this post before attempting these questions



  1. Sort a Python list based on number of 0s in a numbered list.
    a=[100,2,101]
    sorted list =[2,101,100]
  2. Sort a Python list of numbers based on odd or even. Odd numbers will come first.
    a=[11,2,34,60,33,45]
    sorted list=[11,33,45,2,34,60]
  3. Sort a Python list of 3 number Tuples based on their sum.
    a=[(1,2,3),(1,1,1),(2,5,4),(0,1,0)]
    sorted list=[(0,1,0),(1,1,1),(1,2,3),(2,5,4)]
  4. Sort a list of date tuples.
    a=[(19,3,2022),(16,1,1970),(15,8,1947),(31,12,1946)]
    sorted list=[(31,12,1946),(15,8,1947),(16,1,1970),(19,3,2022)]
  5. Sort a list of words based on number of vowels.
    a=["Python","Java","C","Fortran","Pascal"]
    sorted list=["C","Python","Java","Fortran","Pascal"]


Contact us for software training, education or development










 

Post a Comment

0 Comments