• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 75 pages
Exam (elaborations)

COGS 108 Assignment 1: git & Python | 2026 Update with complete solutions GRADE A+

Document preview thumbnail
Preview 4 out of 75 pages

COGS 108 Assignment 1: git & Python | 2026 Update with complete solutions GRADE A+

Content preview

COGS 108 ASSIGNMENT 1: GIT &
PYTHON | 2026 UPDATE WITH
COMPLETE SOLUTIONS.
148 Questions with Answers and Detailed Rationales


100 PERCENT GUARANTEED PASS


INSTANT DOWNLOAD ANSWERS INCLUDED



IMPORTANCE OF THIS DOCUMENT
This comprehensive examination preparation guide has been meticulously developed to help you succeed in the
COGS 108 ASSIGNMENT 1: GIT & PYTHON | 2026 UPDATE WITH COMPLETE SOLUTIONS.. It contains 148
carefully selected questions that reflect the most current exam content and testing strategies. Each question is
accompanied by a correct answer and a detailed rationale that explains the underlying pathophysiology,
pharmacology, or clinical reasoning.

Self-Assessment – Test your knowledge and Exam Preparation – Familiarize yourself with the
identify areas requiring further question format and content
study areas

Concept Reinforcement – Deepen your Confidence Building – Develop test-taking
understanding through strategies and reduce
evidence-based exam anxiety
rationales
Time Management – Practice answering
questions under simulated
exam conditions




Review Summary 148 Questions


Foundations - Application - COGS 108 Assignment 1 GIT & Python 2026 Update WITH Complete Solutions
Cognitive Science / DATA Science Version Control WITH GIT AND Python Programming Fundamentals
Undergraduate Lower Division YEAR 1 2 Introductory DATA Science / Cognitive Science
All answers with rationales

,Table of Contents

Content Area Questions Key Topics

Version Control WITH GIT 1-25 Student, Commit, Python, Command, Analysis


Python Basics AND Syntax 26-50 Branch, Repository, Command, Return, Commit


DATA Types AND Variables 51-75 Python, Commit, RUNS GIT, Merge, Conflict


Control FLOW AND Loops 76-100 Commit, Python, Student, Wants, Command


Functions AND Modules 101-125 Student, Commit, Command, RUNS GIT, Merge


FILE Input/output 126-148 Commit, Dataframe, Expression, Returns, Python


TOTAL 148 All questions include answers and detailed rationales

,Section A - Version Control WITH GIT

Q1.
A student runs `git add analysis.py` and then edits analysis.py again before running `git
commit -m "first draft"`. What does the resulting commit contain?


A. The file content as it existed at the B. The file content as it existed when `git
moment of the commit, including the second add` was executed, not the second edit.
edit.

C. An error, because git refuses to commit a D. Both versions stored as a merge,
file that changed after staging. requiring manual conflict resolution.
Correct: B - The file content as it existed when `git add` was executed, not the second edit.


Rationale:`git add` snapshots the file into the staging area (index); subsequent edits live only
in the working directory and are not part of the commit until re-staged. Git does not error on
post-staging edits, and no automatic merge of working-directory changes occurs.
Why the other answers are wrong:
A. The commit records the staged snapshot, not the later working-directory edit.
C. Git silently commits the staged version; it does not raise an error for unstaged changes.
D. Merges occur between branches/commits, not between a staged snapshot and an unstaged
working edit.
Reference: Chacon & Straub (2024). Pro Git, 2nd Ed., Ch. 2.2 'Recording Changes to the Repository'.


Q2.
In a Jupyter notebook, a student defines `x = 10` in cell 1, runs cell 3 (which prints `x`),
then edits cell 1 to `x = 20` and re-runs only cell 3. What is printed, and why does this
illustrate a reproducibility hazard?


A. 20, because Jupyter re-evaluates all prior B. 10, because the kernel retains the old
cells automatically before running any cell. value until cell 1 is re-executed, illustrating
hidden state.

C. An error, because Jupyter invalidates the D. 20, because notebook cells share
kernel whenever an upstream cell is edited. variables through disk files rather than
kernel memory.
Correct: B - 10, because the kernel retains the old value until cell 1 is re-executed,
illustrating hidden state.


Rationale:Jupyter's kernel is a persistent Python process; editing a cell's source does not
re-execute it. The kernel still holds x = 10, so cell 3 prints 10 - a classic 'hidden state' problem
that makes out-of-order execution hard to reproduce.
Why the other answers are wrong:




Page 3

, Section A - Version Control WITH GIT

A. Jupyter does not automatically re-run upstream cells; execution is manual and

order-dependent.

C. Editing cell source does not restart or invalidate the kernel.

D. Variables live in the kernel's memory, not in disk files shared between cells.

Reference: Rule et al. (2019). 'Ten Simple Rules for Reproducible Research in Jupyter Notebooks.'
PLOS Computational Biology, Rule 3.


Q3.
Given `nums = [1, 2, 3, 4, 5, 6]`, which expression produces `[4, 16, 36]`?


A. [n**2 for n in nums if n % 2 == 0] B. [n**2 for n in nums if n % 2 == 1]

C. [n*2 for n in nums if n % 2 == 0] D. [n**2 for n in nums if n > 3]
Correct: A - [n**2 for n in nums if n % 2 == 0]


Rationale:The target list squares the even numbers 2, 4, 6, giving 4, 16, 36. Option A filters
for even numbers (`n % 2 == 0`) and squares each, matching exactly.
Why the other answers are wrong:
B. Filtering odd numbers yields 1, 9, 25, not the target.
C. Doubling even numbers yields 4, 8, 12, not squares.
D. Filtering n > 3 includes odd 5 and yields 16, 25, 36.
Reference: Downey, A. (2024). Think Python, 3rd Ed., Ch. 10 'Lists' and Ch. 12 'Comprehensions'.


Q4.
A collaborator has pushed new commits to the remote `main` while you made local
commits on your own `main`. After `git pull` reports a conflict in `utils.py`, what is the
correct immediate next step?


A. Run `git push --force` to overwrite the B. Delete your local branch and re-clone the
remote with your local version. repository from scratch.

C. Open utils.py, resolve the conflict D. Run `git reset --hard HEAD~1` to discard
markers, then `git add` and `git commit`. your last local commit.
Correct: C - Open utils.py, resolve the conflict markers, then `git add` and `git commit`.


Rationale:A merge conflict means git could not auto-merge; the developer must manually edit
the file to resolve conflict markers, stage the resolved file, and commit to finalize the merge.
Force-pushing or resetting discards work and does not resolve the conflict.
Why the other answers are wrong:
A. Force-push overwrites remote history and is destructive; it does not resolve the conflict.
B. Re-cloning discards local commits and is unnecessary when the conflict is resolvable.
D. Resetting discards your commit rather than resolving the merge conflict.
Reference: Chacon & Straub (2024). Pro Git, 2nd Ed., Ch. 3.2 'Basic Branching and Merging'.




Page 4

Document information

Uploaded on
September 24, 2026
Number of pages
75
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$24.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ProfReginaBank
4.7
(3)
Sold
20
Followers
2
Items
1486
Last sold
5 days ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions