You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/exercises/file_lab.rst
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,10 @@ Paths and File Processing
16
16
=========================
17
17
18
18
* Write a program which prints the full path for all files in the current
19
-
directory, one per line
19
+
directory, one per line. Use either the ``os`` module or ``pathlib``.
20
20
21
21
* Write a program which copies a file from a source, to a destination
22
-
(without using shutil, or the OS copy command).
23
-
24
-
- Advanced: make it work for any size file: i.e. don't read the entire
25
-
contents of the file into memory at once.
22
+
(without using shutil, or the OS copy command (you are essentially writing a simple version of the OS copy command)).
26
23
27
24
- This should work for any kind of file, so you need to open
28
25
the files in binary mode: ``open(filename, 'rb')`` (or ``'wb'`` for
@@ -31,6 +28,9 @@ Paths and File Processing
31
28
32
29
- Test it with both text and binary files (maybe a jpeg or something of your choosing).
33
30
31
+
- Advanced: make it work for any size file: i.e. don't read the entire
32
+
contents of the file into memory at once.
33
+
34
34
- This should only be a few lines of code :-)
35
35
36
36
@@ -43,9 +43,9 @@ Download this text file:
43
43
44
44
In it, you will find a list of names and what programming languages they have used in the past. This may be similar to a list generated at the beginning of this class.
45
45
46
-
Write a little script that reads that file, and generates a list of all the languages that have been used.
46
+
Write a little script that reads that file and generates a list of all the languages that have been used.
47
47
48
-
What might be the best data structure to use to keep track of bunch of values without duplication?
48
+
What might be the best data structure to use to keep track of bunch of values (the languages) without duplication?
49
49
50
50
The file format:
51
51
----------------
@@ -62,5 +62,7 @@ So a colon after the name, then the nickname, and then one or more languages.
62
62
63
63
However, like real data files, the file is NOT well-formed. Only some lines have nicknames, and other small differences, so you will need to write some code to make sure you get it all correct.
64
64
65
+
How can you tell the difference between a nickname and a language?
66
+
65
67
Extra challenge: keep track of how many students specified each language.
0 commit comments