Difference between revisions of "CSC111 Exercises with Lists"

From dftwiki3
Jump to: navigation, search
Line 5: Line 5:
  
 
=Exercise 2=
 
=Exercise 2=
Split a line into a list of words
+
;Question 1
 +
: Split a line of text into a list of words.
 +
 
 +
;Question 2
 +
: Reformat the list of words as a string with the |-character as separator instead of a space
 +
 
 
=Exercise 3=
 
=Exercise 3=
 
;Question 1
 
;Question 1

Revision as of 09:05, 24 March 2014

--D. Thiebaut (talk) 09:53, 24 March 2014 (EDT)


Exercise 1

Create a list with all the odd numbers between 1 and 100.

Exercise 2

Question 1
Split a line of text into a list of words.
Question 2
Reformat the list of words as a string with the |-character as separator instead of a space

Exercise 3

Question 1
Given the text in this page which represents lists of media files, create a list of just the names of the files.
Question 2
Given the text in the same page, find the file that takes the most amount of disk space.
Question 3
List the files as a name followed by a size, one per line
Question 4
Same as Question 3, but sort the list alphabetically
Question 5
Same as Question 3, but sort the list by file size
Question 6
Create a new list that contains only the size, month, day, year and file name for each file. In other words, drop the first 4 fields of each line.