Title: Midterm Exam
Course: AIINFRA 100: AI Systems & Development Environments > Section: Week 08 — Collaborative Development with GitHub — Midterm

📝 Midterm Exam (100 pts)

The following includes model answers for instructor reference. This answer key is hidden from students in the actual quiz interface.

Part A — Applied Task (40 pts)

Scenario: You're kicking off a new small project called weather-notes. Set it up the way a professional would on day one:

1. Create a project folder named weather-notes and open it in VS Code.
2. Create and activate a virtual environment for the project (using venv, or uv if you prefer).
3. Create two files: a notes.py with a single function that returns a short weather-related string, and a requirements.txt (or pyproject.toml) listing at least one dependency (e.g., requests).
4. Initialize a git repository in the project folder.
5. Make at least two commits that tell a clear story of progress (e.g., first commit adds the initial files, second commit adds a small improvement to notes.py).

Describe, step by step, the terminal commands and VS Code actions you would take to complete this scenario. → Model answer:

mkdir weather-notes
cd weather-notes
code .

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate        # macOS/Linux
# .venv\Scripts\activate          # Windows

# (or with uv)
# uv venv
# source .venv/bin/activate

# Create project files
echo "requests" > requirements.txt
# create notes.py in VS Code with a function like:
#   def get_weather_note():
#       return "It's a good day to check the weather!"

# Initialize git and make the first commit
git init
git add notes.py requirements.txt
git commit -m "Add initial notes.py and requirements"

# Make a small improvement, then commit again
# (e.g., edit notes.py to add a docstring or a second function)
git add notes.py
git commit -m "Add docstring to get_weather_note"

A correct answer sets up a virtual environment before installing dependencies, keeps the repo scoped to the project folder, and shows two commits with meaningful, incremental messages (not just "commit 1", "commit 2").

Part B — Short Answer / Multiple Choice (60 pts, 5 pts each)

1. (Dev Environments) What is the main purpose of a code editor's integrated terminal, like the one in VS Code? → It lets you run commands (like scripts, git, or package installs) without leaving the editor window. 2. (Python Fundamentals — MC) Which of the following is a valid way to define a function in Python? A) function myFunc(): B) def myFunc(): C) func myFunc(): D) define myFunc(): → B) def myFunc(): 3. (Python Fundamentals — TF) True or False: In Python, indentation is purely stylistic and does not affect how code runs. → False. Indentation defines code blocks (e.g., inside functions, loops, and conditionals) and changing it can change — or break — program behavior. 4. (VS Code) What is the purpose of a VS Code extension like the Python extension? → It adds language-specific features to the editor, such as syntax highlighting, linting, IntelliSense/autocomplete, and debugging support for Python. 5. (Git Basics — MC) Which command stages a file for the next commit? A) git commit B) git add C) git push D) git status → B) git add 6. (Git Basics) What does git commit -m "message" do? → It saves a snapshot of the currently staged changes to the repository's history, along with a descriptive message explaining what changed. 7. (Advanced Git — TF) True or False: A git branch lets you work on changes in isolation without affecting the main line of development until you merge. → True. 8. (Advanced Git) What is the purpose of a .gitignore file? → It tells git which files or folders to exclude from version control (e.g., virtual environment folders, cache files, secrets), keeping the repo clean. 9. (GitHub Collaboration — MC) What is the primary purpose of a pull request on GitHub? A) To delete a branch B) To propose and review changes before merging them into another branch C) To download a repository D) To create a new GitHub account → B) To propose and review changes before merging them into another branch 10. (GitHub Collaboration) Why might a team use GitHub Issues alongside a repository? → To track bugs, feature requests, and tasks in a way that's linked directly to the code, making it easy to discuss and reference specific work. 11. (Virtual Environments — TF) True or False: The purpose of a virtual environment is to isolate a project's dependencies so they don't conflict with other projects or the system-wide Python installation. → True. 12. (Virtual Environments) Name one benefit of creating a dedicated virtual environment (e.g., with venv) for each project rather than installing all packages system-wide. → Each project gets its own isolated set of dependencies at specific versions, so upgrading or installing a package for one project can't break another project or the system Python; it also makes the project easier to reproduce and share (e.g., via requirements.txt).