1 of 20

Binary Tree

Digital Literacy Training

2 of 20

Week 3

Files and File Handling

3 of 20

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.

4 of 20

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.

5 of 20

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.

6 of 20

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.

7 of 20

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.

8 of 20

Using Files

Here are the basics of using files:

  • Use meaningful names: Give your files names that reflect their content. For example, instead of "document1.docx," use "report_sales_q3.docx."
  • Organize with folders: Create folders to group related files. This makes it easier to find what you need.
  • Use a consistent naming convention: Develop a system for naming files, such as using underscores or hyphens to separate words.
  • Backup your files: Make copies of important files to protect them from loss.
  • Use cloud storage: Store files online to access them from any device (ex. Google drive).
  • Compress files: Reduce file size to save space and transfer time.
  • Share files securely: Use password protection or encryption to keep sensitive files private.
  • Learn keyboard shortcuts: Use keyboard shortcuts to quickly create, open, and manage files.

9 of 20

Programming Logic and Pseudocode

  • What is Programming Logic?
    • Definition: The sequence of steps and decisions a computer follows to solve a problem.
    • Why it’s Useful: It ensures programs run correctly as well as helping you think critically and solve problems. Makes your code easier to understand and maintain.
  • What is Pseudocode?
    • Definition: A simplified way to write out the steps of a program using plain English.
    • Why it's Useful: Helps you plan your code before writing it. Makes your logic easier to understand and debug. Can be used to communicate your ideas to others.

10 of 20

Programming Logic and Pseudocode

  • Tips for developing a solid programming logic
    • Visualizing Logic with Flowcharts
    • Practice, practice, practice
    • Don't be afraid to ask for help
    • Start with small, simple problems and gradually work your way up to more complex ones
    • Break down large problems into smaller, more manageable ones
    • Test your code thoroughly to make sure it works as expected

11 of 20

An Introduction to Conditionals and Loops

  • What are conditionals?
    • Conditionals are programming statements that allow you to make decisions based on certain conditions. For example, an "if" statement checks if a condition is true, and if it is, it executes a specific block of code.
  • What are loops?
    • Loops are programming constructs that allow you to repeat a block of code multiple times. There are two main types of loops: "for" loops and "while" loops. A "for" loop is used 1 when you know the number of times you want to repeat 2 the code, while a "while" loop is used when you want to repeat the code as long as a certain condition is true.

12 of 20

An Introduction to Conditionals and Loops

  • If-elif-else statement
    • if: The first condition is checked. If it's true, the code inside the if block is executed.
    • elif: If the first condition is false, the next elif condition is checked. If it's true, the code inside the elif block is executed. You can have multiple elif blocks.
    • else: If none of the previous conditions are true, the code inside the else block is executed.
  • Case Statement
    • A case statement, also known as a switch statement, allows you to execute different code blocks based on the value of an expression. It's a way to efficiently handle multiple conditions.

13 of 20

If-else example

14 of 20

Case example

15 of 20

An Introduction to Conditionals and Loops

  • For Loop
    • A for loop iterates over a certain sequence of items, such as a list or a set of numbers. It executes a block of code for each iteration. For example, if you have a list of fruits and wanted to print them out, you can use a for loop to iterate over all of the elements and print them out one by one.
  • While Loop
    • A while loop repeatedly executes a block of code as long as a certain condition is true. Its useful for tasks that are done repeatedly until something is finished. For example, a lot of games use while loops to decide when all of the player’s lives are over by checking if a variable(ex. var isGameOver) is true or not and then proceed.

16 of 20

For Loop Example

Output

17 of 20

While Loop Example

18 of 20

Example: Research a virtual environment software and how it was created

Objective:

  • Understand the relationship between virtual environments, files, and code logic.

Instructions:

  1. Choose a virtual environment software (e.g., Python’s venv, Docker, or VirtualBox).

  1. Research the following:

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.

19 of 20

Example: Research a virtual environment software and how it was created

Task:

Examine the kinds of files virtual environments create, such as:

  • requirements.txt (Python): Lists project dependencies.
  • Dockerfiles: Define application environments for containers.
  • Config files: Store specific environment settings.

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.

20 of 20

Example: Research a virtual environment software and how it was created

Scenario:

  • You’re debugging a project that requires specific library versions. Without a virtual environment, your code throws errors.

Task:

  1. Research how virtual environments use code logic (like automation scripts) to install and manage dependencies.
  2. Identify and describe the logic behind commands like:

• 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?