0% found this document useful (0 votes)
1 views1 page

File Path PPS Abhishek

A file path indicates the location of a file or folder in a computer system, with two main types: absolute and relative paths. Absolute paths provide the full path from the root directory, while relative paths are shorter and based on the current working directory. Python supports both types for file handling.

Uploaded by

aksharabhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

File Path PPS Abhishek

A file path indicates the location of a file or folder in a computer system, with two main types: absolute and relative paths. Absolute paths provide the full path from the root directory, while relative paths are shorter and based on the current working directory. Python supports both types for file handling.

Uploaded by

aksharabhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

File Path in Python - PPS (SPPU FE)

What is a File Path?

A file path is the location or address of a file/folder in the computer system. It tells the system where to find or save a file.

Types of File Paths:

1. Absolute Path
2. Relative Path

1. Absolute Path

- Full path from the root directory.


- Always points to the same location.

Examples:
Windows: C:/Users/Abhishek/Documents/data.txt
Linux: /home/abhishek/documents/data.txt

In Python:
file = open("C:/Users/Abhishek/Documents/data.txt", "r")

2. Relative Path

- Path relative to the current working directory.


- Shorter and used in projects.

Example:
files/data.txt

In Python:
file = open("files/data.txt", "r")

Comparison Table

Feature | Absolute Path | Relative Path


----------------|----------------------------------|-------------------------
Starts from | Root folder | Current directory
Portability | Less portable | More portable
Use case | Fixed file location | Used in projects
Example | C:/Users/Abhishek/file.txt | files/file.txt

Summary

- File path = Location of a file on the computer.


- Absolute path: Full path from root.
- Relative path: Path from current folder.
- Python supports both for file handling.

You might also like