Quiz: Folders and paths
Try each question before opening its hint or answer.
Q1. In the course project, data and reports are both directly inside introcomputing-course. Is reports inside data? What is their parent folder?
Draw the tree with indentation.
No, they are neighbours. Their parent is the project folder, introcomputing-course.
Q2. Which of these paths is absolute and which is relative: /Users/anna/Documents/introcomputing-course/data/seedlings.csv and data/seedlings.csv?
Where does each path start?
The first is absolute: it starts at the top of the disk (/). The second is relative: it starts from an agreed folder, here the project folder.
Q3. From the project folder, data/seedlings.csv finds the measurements. From inside reports, where does the same path point?
A relative path starts from the current folder.
To a data folder inside reports, which does not exist. Go up to the project folder first (written ../data/seedlings.csv from reports).
Q4. Anna’s R code reads C:\Users\anna\Documents\introcomputing-course\data\seedlings.csv. Ben runs it on his laptop. What happens, and what should Anna write instead?
Which part of the path is specific to Anna’s laptop?
It fails, because Ben’s laptop has no folder C:\Users\anna. Anna should write the relative path data/seedlings.csv, which works for anyone who opens the project folder.
Q5. You move the folder practice/map-a into practice/map-b. Does note.txt inside it change? What is its new path from the project folder?
Compare the contents of the file with its location.
The contents stay the same; only the location changes. The new path is practice/map-b/map-a/note.txt.
Q6. You add a sentence to a note, close the editor and choose Don’t save. What is in the file when you reopen it?
Where does unsaved text live?
The last saved version, without the new sentence. Unsaved text lives in working memory and disappears when the program closes; saved text is on disk.