• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 75 páginas
Examen

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

Document preview thumbnail
Vista previa 4 fuera de 75 páginas

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

Vista previa del contenido

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

Información del documento

Subido en
24 de septiembre de 2026
Número de páginas
75
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$24.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
ProfReginaBank
4.4
(5)
Vendido
45
Seguidores
2
Artículos
2543
Última venta
3 días hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes