Question 1 of 17
Quick Check: Python Paths and pathlib
Check your understanding of path construction, traversal, path identity, lexical normalization, text and bytes path representations, path drive/root/tail decomposition, home and environment-variable expansion, path resolution, and selected os.path behavior.
Knowledge check
Quick Check: Python Paths and pathlib
Check your understanding of path construction, traversal, path identity, lexical normalization, text and bytes path representations, path drive/root/tail decomposition, home and environment-variable expansion, path resolution, and selected os.path behavior.
- Stuck? Each question has an optional hint.
- Skip a hard question and review it before your results.
- Questions and answer options can shuffle between attempts.
You can retake this quiz whenever you like.
Question 2 of 17
How should you combine path components with pathlib?
Question 3 of 17
What does path.suffix return for reports/summary.csv?
Question 4 of 17
What does with_suffix() do?
Question 5 of 17
Which operation actually queries the filesystem?
Question 6 of 17
Which pathlib method yields only entries directly inside a directory?
Question 7 of 17
Which expression finds .csv files in root and in its nested directories?
Question 8 of 17
Which statement about recursive pathlib globbing is correct?
Question 9 of 17
Why should new code use os.path.commonpath() rather than os.path.commonprefix() to find a shared directory?
Question 10 of 17
Which statement about expanding a home-directory shortcut is correct?
Question 11 of 17
Which description best distinguishes Path.absolute() from Path.resolve()?
Question 12 of 17
A target is outside base. Which operation can still compute a relative route containing .. components?
Question 13 of 17
Two path names have different spellings, but both point to the same existing file. Which operation checks filesystem identity?
Question 14 of 17
What does os.path.normpath() do, and what does it not guarantee?
Question 15 of 17
What happens when os.path.basename() receives a bytes path?
Question 16 of 17
What does os.path.expandvars() do when a referenced environment variable is not set?
Question 17 of 17
What does os.path.splitroot(path) return, and what does that tell you about the input path?
Quiz results
Review
-
What does creating Path('reports') do?Hint used
-
How should you combine path components with pathlib?Hint used
-
What does path.suffix return for reports/summary.csv?Hint used
-
What does with_suffix() do?Hint used
-
Which operation actually queries the filesystem?Hint used
-
Which pathlib method yields only entries directly inside a directory?Hint used
-
Which expression finds .csv files in root and in its nested directories?Hint used
-
Which statement about recursive pathlib globbing is correct?Hint used
-
Why should new code use os.path.commonpath() rather than os.path.commonprefix() to find a shared directory?Hint used
-
Which statement about expanding a home-directory shortcut is correct?Hint used
-
Which description best distinguishes Path.absolute() from Path.resolve()?Hint used
-
A target is outside base. Which operation can still compute a relative route containing .. components?Hint used
-
Two path names have different spellings, but both point to the same existing file. Which operation checks filesystem identity?Hint used
-
What does os.path.normpath() do, and what does it not guarantee?Hint used
-
What happens when os.path.basename() receives a bytes path?Hint used
-
What does os.path.expandvars() do when a referenced environment variable is not set?Hint used
-
What does os.path.splitroot(path) return, and what does that tell you about the input path?Hint used