Prerequisites — Exercises

Try these without looking at the solutions first. They combine everything you learned.


Exercise 1: Project Setup (Terminal + Git + Markdown)

  1. Create a folder called my-portfolio in /tmp
  2. Inside it, create these files: README.md, about.md, projects.md
  3. Initialize a git repository
  4. Write a README.md with:
  5. Your name as a heading
  6. A short bio in a paragraph
  7. A list of skills
  8. A link to your GitHub
  9. Stage and commit with message "Initial commit"
  10. Add a line to about.md, stage and commit with message "Add about page"

Exercise 2: Python Word Counter

Write a Python script counter.py that:

  1. Reads a text file provided as a command-line argument
  2. Counts the number of lines, words, and characters
  3. Prints the results in a formatted table

Example output:

File: sample.txt
Lines:    12
Words:    145
Chars:    823

Test it with a file you create.


Exercise 3: TypeScript Data Fetcher

Write a TypeScript script weather.ts that:

  1. Defines an interface Weather with temperature, condition, and city
  2. Fetches from https://jsonplaceholder.typicode.com/todos/1 (not real weather, but practice)
  3. Maps the response to a Weather-like object
  4. Prints "City: {city}, Temperature: {temp}°C, Condition: {condition}"

Exercise 4: Git Workflow Challenge

  1. Create a new folder /tmp/git-flow and init a git repo
  2. Create a file main.py with print("Hello") — commit
  3. Create a branch called feature/greet
  4. On that branch, modify main.py to ask for a name and greet them
  5. Commit the change
  6. Switch back to main
  7. Merge feature/greet into main
  8. Delete the feature branch
  9. View the log to verify

Exercise 5: Cross-Topic Challenge

Combine everything:

  1. Create a folder cross-challenge and init git
  2. Write a Python script data.py that generates 100 random "people" (name, age, city) and saves as people.json
  3. Write a TypeScript script report.ts that reads people.json, filters to people over 18, and prints a markdown-formatted table of results
  4. Write the output to a file adults.md
  5. Commit all changes with a good commit message
  6. View the log and diff

Exercise 6: Bash Pipeline

Write a one-liner command that:

  1. Finds all .py files in the current directory
  2. Counts the total lines of Python code
  3. Saves the count to loc.txt

Hint: use find, xargs, wc, and >.


Exercise 7: Markdown to HTML

Create a markdown file recipe.md for your favorite recipe that includes: - A heading with the recipe name - An ingredients list (unordered) - Step-by-step instructions (ordered) - A bold tip at the end - A code block with the cooking time in minutes

Then use a markdown-to-HTML converter (many exist online) to see it rendered.