This is an old revision of the document!


03. Making the list

Solve these subtasks all in the same file (use print() statements to display the results):

  • Use the following list:
    sample = ["a", 90, 8, "X55", "1z", 102, "asdf", 65, 10, "word", "567", 567]
  • Print the sorted list;
  • Filter out all non-numbers in the list (note: those values of the int type should remain!)… can you make it using a single line of code? now it's the time to introduce list comprehensions;
  • Print the original list (too easy? there's always a catch :P);
  • Define a function that builds a matrix filled with numbers from 1 to n like the following example:
    m = [[1, 2, 3, 4],
         [4, 1, 2, 3],
         [3, 4, 1, 2],
         [2, 3, 4, 1]]
ii/labs/s2/01/tasks/03.1679161179.txt.gz · Last modified: 2023/03/18 19:39 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0