Bird
0
0

What does the Path.home() method return in Python's pathlib module?

easy📝 Conceptual Q2 of 15
Python - File Handling Fundamentals
What does the Path.home() method return in Python's pathlib module?
AThe user's home directory
BThe root directory of the filesystem
CThe current working directory
DThe directory of the running script
Step-by-Step Solution
Solution:
  1. Step 1: Understand Path.home() method

    Path.home() returns the home directory of the current user, like /home/user or C:\Users\user.
  2. Step 2: Differentiate from other directories

    Current working directory is Path.cwd(), root is '/', script directory is different.
  3. Final Answer:

    The user's home directory -> Option A
  4. Quick Check:

    Path.home() = user's home directory [OK]
Quick Trick: Path.home() gives your user folder path [OK]
Common Mistakes:
  • Confusing with current directory
  • Thinking it returns root directory
  • Assuming script location

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes