Skip to content
Snippets Groups Projects
Commit ab25a19e authored by Anna Meyer's avatar Anna Meyer
Browse files

exam 1 review notebook

parent 96431a15
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:482016d5 tags:
# Exam 1 review
%% Cell type:markdown id:96330469 tags:
## Arguments
%% Cell type:code id:138a92cc tags:
``` python
def person(name, age, color='blue', animal='cat'):
print(name, " is ", age, " years old ", end="")
print("their favorite color is ",color, end="")
print(" and their favorite animal is ",animal)
```
%% Cell type:code id:a5f2edbc tags:
``` python
# TODO: what are all the ways we can (or cannot) call person()?
```
%% Cell type:markdown id:6f623b4b tags:
## Function Scope
%% Cell type:markdown id:e54320ef tags:
### Example 1 -- basic function scope
%% Cell type:code id:7e4d570a tags:
``` python
pi = 3.14
alpha = 4
def my_func(alpha, beta):
# TODO: what variables are accessible at line 5? what values do they have?
delta = alpha + beta
gamma = delta ** 2
return gamma
answer = my_func(alpha, pi)
answer2 = my_func(answer, alpha)
# TODO what variables are accessible here? What values do they have?
```
%% Cell type:markdown id:33a302bf tags:
### Example 2 -- global vs. local
%% Cell type:code id:7a5ed848 tags:
``` python
two = 3.14
alpha = 4
def my_func1(alpha, beta):
# TODO: what variables are accessible at line 5? what values do they have?
delta = alpha + beta
gamma = delta * two
return gamma
answer = my_func(alpha, two)
# TODO what variables are accessible here? What values do they have?
```
%% Cell type:code id:04428811 tags:
``` python
two = 2
alpha = 14
def my_func2(alpha, beta):
# TODO: what variables are accessible at line 5? what values do they have?
delta = alpha + beta
two = 7
gamma = delta * two
return gamma
answer = my_func(alpha, two)
# TODO what variables are accessible here? What values do they have?
```
%% Cell type:code id:51696c45 tags:
``` python
two = 2
alpha = 14
def my_func3(alpha, beta):
# TODO: what variables are accessible at line 5? what values do they have?
delta = alpha + beta
gamma = delta * two
two = 7
return gamma
answer = my_func(alpha, two)
# TODO what variables are accessible here? What values do they have?
```
%% Cell type:code id:6cdb7a02 tags:
``` python
two = 2
alpha = 14
def my_func3(alpha, beta):
# TODO: what variables are accessible at line 5? what values do they have?
delta = alpha + beta
global two
gamma = delta * two
two = 7
return gamma
answer = my_func(alpha, two)
# TODO what variables are accessible here? What values do they have?
```
%% Cell type:markdown id:2ebbfa8b tags:
## Refactoring
%% Cell type:markdown id:c61c0d46 tags:
### Example 1
%% Cell type:code id:7e25ba85 tags:
``` python
def some_func():
if some_cond1:
if some_cond2:
if some_cond3:
return True
return False
```
%% Cell type:code id:d6dc250a tags:
``` python
# TODO how can we rewrite some_func() to only use 1 line of code?
def some_func_short():
pass
```
%% Cell type:markdown id:b9da2d00 tags:
### Example 2
%% Cell type:code id:678f8ec2 tags:
``` python
def some_func_1(x, y, z):
if x >= 7:
return True
if y < 18:
return True
if z == 32:
return True
else:
return False
```
%% Cell type:code id:d1bf3938 tags:
``` python
# TODO which of these refactoring options is correct?
def some_func_1a(x, y, z):
return x >= 7 or y < 18 or z == 32
def some_func_1b(x, y, z):
return x >= 7 and y < 18 and z == 32
```
%% Cell type:code id:063829c0 tags:
``` python
# TODO
# Discuss: given two possible versions of a function (where one is correct),
# what is the general strategy for figuring out which one is correct?
```
# Project 7 (P7): Drinking Water Accessibility
## Corrections and clarifications:
* None yet.
**Find any issues?** Create a post on Piazza
## Instructions:
This project will focus on **utilizing lists** and **managing dictionaries**. To start, download [`p7.ipynb`](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/blob/main/sum23/projects/p7/p7.ipynb), [`p7_test.py`](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/blob/main/sum23/projects/p7/p7_test.py), and [`water_accessibility.csv`](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/blob/main/sum23/projects/p7/water_accessibility.csv).
**Note:** Please go through [Lab 7](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/tree/main/sum23/labs/lab7) before you start the project. The lab contains some very important information that will be necessary for you to finish the project.
You will work on `p7.ipynb` and hand it in. You should follow the provided directions for each question. Questions have **specific** directions on what **to do** and what **not to do**.
After you've downloaded the file to your `p7` directory, open a terminal window and use `cd` to navigate to that directory. To make sure you're in the correct directory in the terminal, type `pwd`. To make sure you've downloaded the notebook file, type `ls` to ensure that `p7.ipynb`, `p7_test.py`, and `water_accessibility.csv` are listed. Then run the command `jupyter notebook` to start Jupyter, and get started on the project!
**IMPORTANT**: You should **NOT** terminate/close the session where you run the above command. If you need to use any other Terminal/PowerShell commands, open a new window instead. Keep constantly saving your notebook file, by either clicking the "Save and Checkpoint" button (floppy disk) or using the appropriate keyboard shortcut.
------------------------------
## IMPORTANT Submission instructions:
- Review the [Grading Rubric](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/blob/main/sum23/projects/p7/rubric.md), to ensure that you don't lose points during code review.
- You must **save your notebook file** before you run the cell containing **export**.
- Login to [Gradescope](https://www.gradescope.com/) and upload the zip file into the p7 assignment.
- If you completed the project with a **partner**, make sure to **add their name** by clicking "Add Group Member"
in Gradescope when uploading the P7 zip file.
<img src="images/add_group_member.png" width="400">
- It is **your responsibility** to make sure that your project clears auto-grader tests on the Gradescope test system. Otter test results should be available in a few minutes after your submission. You should be able to see both PASS / FAIL results for the 20 test cases and your total score, which is accessible via Gradescope Dashboard (as in the image below):
<img src="images/gradescope.png" width="400">
- If you feel you have been incorrectly graded on a particular question during manual review, then you can submit a regrade request.
sum23/projects/p7/images/add_group_member.png

157 KiB

sum23/projects/p7/images/autograder_success.png

41.3 KiB

sum23/projects/p7/images/gradescope.png

150 KiB

This diff is collapsed.
This diff is collapsed.
# Project 7 (P7) grading rubric
## Code reviews
- A TA / grader will be reviewing your code after the deadline.
- They will make deductions based on the Rubric provided below.
- To ensure that you don’t lose any points in code review, you must review the rubric and make sure that you have followed the instructions provided in the project correctly.
## Rubric
### General deductions:
- Did not save the notebook file prior to running the cell containing "export". We cannot see your output if you do not save before generating the zip file. This deduction will become stricter for future projects. (-3)
- Used concepts/modules (ex: pandas) not covered in class yet (You may use built-in functions that you have been instructed to use) (-3)
- import statements are not mentioned in the required cell at the top of the notebook (-1)
- Hardcoded answers or data structures (full points)
### Question specific guidelines:
- `cell` (3)
- Function does not typecast based on column names (-1)
- Function does not multiply the values in the pop column by 1000 (-1)
- Function is defined more than once (-1)
- Q1 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q2 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q3 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q4 (4)
- Incorrect logic is used to answer (-1)
- Recomputed variable defined in Q3 (-1)
- Required functions are not used to answer (-1)
- Q5 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q6 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q7 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- Q8 (5)
- Incorrect logic is used to answer (-2)
- Hardcoded income levels (-1)
- Required functions are not used to answer (-1)
- Q9 (4)
- Incorrect logic is used to answer (-2)
- Required functions are not used to answer (-1)
- `get_col_dict` (3)
- Incorrect logic is used in function (-2)
- Function is defined more than once (-1)
- `dict_2015` (3)
- Data structure is defined incorrectly (-3)
- `dict_2020` (3)
- Data structure is defined incorrectly (-3)
- Q10 (2)
- Required data structures are not used to answer (-1)
- Q11 (2)
- Required data structures are not used to answer (-1)
- Q12 (3)
- Incorrect logic is used to answer (-1)
- Required data structures are not used to answer (-1)
- Q13 (4)
- Incorrect logic is used to answer (-2)
- Required data structures are not used to answer (-1)
- Q14 (4)
- Incorrect logic is used to answer (-2)
- Required data structures are not used to answer (-1)
- Q15 (4)
- Incorrect logic is used to answer (-1)
- Recomputed variables already defined in q13 and q14 (-1)
- Required data structures are not used to answer (-1)
- `dict_2015` (2)
- Incorrect rural_alb calculation in data structure (-2)
- `dict_2020` (2)
- Incorrect rural_alb calculation in data structure (-2)
- Q16 (2)
- Required data structures are not used to answer (-1)
- `rural_non_alb_bin_2015_dict` (5)
- Data structure is defined incorrectly (-5)
- `rural_non_alb_bin_2020_dict` (5)
- Data structure is defined incorrectly (-5)
- Q17 (2)
- Required data structures are not used to answer (-1)
- Q18 (4)
- Incorrect logic is used to answer (-2)
- Required data structures are not used to answer (-1)
- Q19 (5)
- Incorrect logic is used to answer (-2)
- Required data structures are not used to answer (-2)
- Q20 (5)
- Incorrect logic is used to answer (-2)
- Required data structures are not used to answer (-2)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment