Binary Tree
Digital Literacy Training
Week 3
Files and File Handling
Files- What are they
PNG (Portable Network Graphics): A raster-graphics file format that supports lossless data compression. PNG is often used for web graphics and images that require transparency. It is ideal for images with text, logos, and other sharp-edged graphics.
MP4 (MPEG-4 Part 14): A digital multimedia container format most commonly used to store video and audio, but it can also be used to store other data such as subtitles and still images. MP4 is highly versatile and compatible with various media players and devices.
Files- What are they
JPEG (Joint Photographic Experts Group): A commonly used method of lossy compression for digital images, especially for those images produced by digital photography. JPEG files are widely used for their small file size and compatibility across different devices and software.
PDF (Portable Document Format): A file format developed by Adobe that allows documents to be presented in a manner independent of application software, hardware, and operating systems. PDFs are commonly used for documents like eBooks, forms, and scanned documents because they maintain formatting and can include text, images, and other media.
Files- What are they
GIF (Graphics Interchange Format): GIF is a bitmap image format supporting up to 256 colors and animations. It’s widely used for memes, web graphics, and lightweight animations due to its small file size. GIFs can be created or manipulated using tools like Python libraries (Pillow) or Adobe software.
ZIP: ZIP is a compressed file format that bundles multiple files into one, reducing their size for easier sharing or storage. It’s especially useful for grouping related files, like project folders or datasets. Tools like zipfile in Python allow programmers to automate compression.
Files- What are they
CSV (Comma Separated Values): CSV files store tabular data in plain text, with values separated by commas. They’re commonly used for exporting and importing data in spreadsheets or databases. CSV files can be read and processed to analyze or clean large datasets in programs like Python. Libraries like pandas(you will learn libraries later) allow for efficient manipulation of rows and columns.
TXT(Plain Text): A TXT file contains unformatted text. It’s simple, lightweight, and universally supported by text editors. Programmers use it for storing code snippets or notes. TXT files are often used for input/output tasks in programming. For example, reading configuration files for an application or storing raw data.
Files - Why are they important?
Files are the fundamental units of digital information, enabling the storage, organization, and sharing of data across devices and platforms. They serve as the structure of modern computing, and provide access to documents, media, and software applications. The ability to transfer files between devices, such as smartphones, tablets, and computers, has significantly improved how we work, learn, and communicate. By standardizing file formats and developing file systems, we have created a universal language for digital content, which means that everything is interoperabile and the exchange of information on a global scale has been made much easier.
Using Files
Here are the basics of using files:
Programming Logic and Pseudocode
Programming Logic and Pseudocode
An Introduction to Conditionals and Loops
An Introduction to Conditionals and Loops
If-else example
Case example
An Introduction to Conditionals and Loops
For Loop Example
Output
While Loop Example
Example: Research a virtual environment software and how it was created
Objective:
Instructions:
File Use: What types of files does the virtual environment create or manage (e.g., configuration files, dependency files)?
Code Execution: How does it help execute code in a reproducible way?
Purpose: Why was it created, and what problem does it solve?
Guidance: Use credible sources and the research techniques covered last week, like evaluating .org or .edu domains.
Example: Research a virtual environment software and how it was created
Task:
Examine the kinds of files virtual environments create, such as:
Example Prompt:
“Imagine you’re working on a Python project. How would you use a requirements.txt file to share
dependencies with your team?”
Follow-Up Discussion:
Discuss how managing these files ensures your code runs on any machine.
Example: Research a virtual environment software and how it was created
Scenario:
Task:
• python -m venv env (creating an environment).
• pip install -r requirements.txt (installing dependencies).
Reflection Prompt:
• How does this automation reduce human error and improve collaboration in coding projects?