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

add p2

parent 19742bb9
No related branches found
No related tags found
No related merge requests found
# Project 2 (P2)
## Clarifications/Corrections:
* None yet.
**Find any issues?** Report to us:
- Ashwin Maran <amaran@wisc.edu>
- Brandon Tran <bqtran2@wisc.edu>
## Note on Academic Misconduct:
Starting from P2, you are **allowed** to work with a partner on your projects. While it is not required that you work with a partner, it is **recommended** that you find a project partner as soon as possible as the projects will get progressively harder. Be careful **not** to work with more than one partner. If you worked with a partner on Lab-P2, you are **not** allowed to finish your project with a different partner. You may either continue to work with the same partner, or work on P2 alone. Now may be a good time to review our [course policies](https://cs220.cs.wisc.edu/s23/syllabus.html).
## Instructions:
In this project, we will focus on types, operators, and boolean logic. To start, create a `p2` directory, and download `p2.ipynb` and `p2_test.py`. Make sure to follow the steps mentioned in [lab-p2](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-s23-projects/-/tree/main/lab-p2#task-21-download-boolipynb-opsipynb-and-modipynb) to download these files.
You will work on `p2.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 `p2` 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 `p2.ipynb` is 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-s23-projects/-/tree/main/p2/rubric.md), to ensure that you don't lose points during code review.
- Login to [Gradescope](https://www.gradescope.com/) and upload the zip file into the P2 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 P2 zip file.
<img src="images/add_group_member.png" width="400">
**Warning:** You will have to add your partner on Gradescope even if you have filled out this information in your `p2.ipynb` notebook.
- 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, which is accessible via Gradescope Dashboard (as in the image below):
<img src="images/gradescope.png" width="400">
Note that you **cannot** view your final score, as TAs haven't manually reviewed your code yet. So, do not worry if you see `-/100.0` as your score.
# Images
Images from p2 are stored here.
sum23/projects/p2/images/add_group_member.png

157 KiB

sum23/projects/p2/images/correct.PNG

15.1 KiB

sum23/projects/p2/images/gradescope.png

150 KiB

sum23/projects/p2/images/semantic_error.PNG

26.5 KiB

sum23/projects/p2/images/syntax_error.PNG

47.7 KiB

Source diff could not be displayed: it is too large. Options to address this: view the blob.
#!/usr/bin/python
import os, json, math
MAX_FILE_SIZE = 500 # units - KB
REL_TOL = 6e-04 # relative tolerance for floats
ABS_TOL = 15e-03 # absolute tolerance for floats
PASS = "PASS"
TEXT_FORMAT = "text" # question type when expected answer is a str, int, float, or bool
expected_json = {"1": (TEXT_FORMAT, 220),
"2": (TEXT_FORMAT, 319),
"3": (TEXT_FORMAT, 168),
"4": (TEXT_FORMAT, int),
"5": (TEXT_FORMAT, int),
"6": (TEXT_FORMAT, float),
"7": (TEXT_FORMAT, str),
"8": (TEXT_FORMAT, bool),
"9": (TEXT_FORMAT, str),
"10": (TEXT_FORMAT, bool),
"11": (TEXT_FORMAT, ':-(:-(:-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-)'),
"12": (TEXT_FORMAT, '2023'),
"13": (TEXT_FORMAT, 216),
"14": (TEXT_FORMAT, 3400.62),
"15": (TEXT_FORMAT, True),
"16": (TEXT_FORMAT, True),
"17": (TEXT_FORMAT, True),
"18": (TEXT_FORMAT, False),
"19": (TEXT_FORMAT, True),
"20": (TEXT_FORMAT, 33.75),}
def check_cell(qnum, actual):
format, expected = expected_json[qnum[1:]]
try:
if format == TEXT_FORMAT:
return simple_compare(expected, actual)
else:
if expected != actual:
return "expected %s but found %s " % (repr(expected), repr(actual))
except:
if expected != actual:
return "expected %s" % (repr(expected))
return PASS
def simple_compare(expected, actual, complete_msg=True):
msg = PASS
if type(expected) == type:
if expected != actual:
if type(actual) == type:
msg = "expected %s but found %s" % (expected.__name__, actual.__name__)
else:
msg = "expected %s but found %s" % (expected.__name__, repr(actual))
elif type(expected) != type(actual) and not (type(expected) in [float, int] and type(actual) in [float, int]):
msg = "expected to find type %s but found type %s" % (type(expected).__name__, type(actual).__name__)
elif type(expected) == float:
if not math.isclose(actual, expected, rel_tol=REL_TOL, abs_tol=ABS_TOL):
msg = "expected %s" % (repr(expected))
if complete_msg:
msg = msg + " but found %s" % (repr(actual))
else:
if expected != actual:
msg = "expected %s" % (repr(expected))
if complete_msg:
msg = msg + " but found %s" % (repr(actual))
return msg
def check(qnum, actual):
msg = check_cell(qnum, actual)
if msg == PASS:
return True
print("<b style='color: red;'>ERROR:</b> " + msg)
def check_file_size(path):
size = os.path.getsize(path)
assert size < MAX_FILE_SIZE * 10**3, "Your file is too big to be processed by Gradescope; please delete unnecessary output cells so your file size is < %s KB" % MAX_FILE_SIZE
# Project 2 (P2) 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 guidelines:
- 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. (-1)
### Question specific guidelines:
- Q2 deduction
- `grad_course_num` variable is hardcoded as 319 (-5)
- Q3 deduction
- `num_cartons` variable is hardcoded as 168 (-5)
- Q5 deduction
- `data_type` variable is hardcoded as int (-5)
- Q6 deduction
- `data_type` variable is hardcoded as float (-5)
- Q7 deduction
- `data_type` variable is hardcoded as str (-5)
- Q8 deduction
- `data_type` variable is hardcoded as bool (-5)
- Q9 deduction
- `data_type` variable is hardcoded as str (-5)
- Q10 deduction
- `data_type` variable is hardcoded as bool (-5)
- Q11 deduction
- `smileys` variable is hardcoded (-5)
- Q12 deduction
- `curr_year` variable is hardcoded as "2023" (-5)
- Q13 deductions
- `cube_volume` variable is hardcoded as 216 (-5)
- `cube_side` variable is not used in `cube_volume` computation (-1)
- Q14 deductions
- `cylinder_volume` variable is hardcoded as 3400.62 (-5)
- `cylinder_radius` variable is not defined, initialized, and used in `cube_volume` computation (-1)
- `cylinder_height` variable is not defined, initialized, and used in `cube_volume` computation (-1)
- Q15 deductions
- `safe_operation` variable is hardcoded as True (-5)
- Expression to compute `safe_operation` is incorrect (-5)
- `TRAILER_LIMIT` and / or `trailer_weight` values are modified (-1)
- Equals comparison was missing (-0.5)
- Q16 deductions
- `safe_operation` variable is hardcoded as True (-5)
- Expression to compute `safe_operation` is incorrect (-5)
- `UPPER_LIMIT` and / or `LOWER_LIMIT` and / or `truck_weight` values are modified (-1)
- Equals comparison was missing (-0.5)
- Q17 deductions
- success variable is hardcoded as True (-5)
- Expression to compute success is changed (-5)
- More than 1 variable's initialization value is changed (-1)
- Q18 deductions
- success variable is hardcoded as False (-5)
- Expression to compute success was not modified correctly (-5)
- Variables `short` and / or `dark` are initialized to different values (-1)
- Q19 deductions
- `primary_color` variable is hardcoded as True (-5)
- Expression to compute `primary_color` is incorrect (-5)
- Variable `color` is initialized to different value (-1)
- Q20 deductions
- `average_score` variable is hardcoded as 33.75 (-5)
- Expression to compute `average_score` is incorrect (-5)
- `alice_score` variables is not defined, initialized, and used in `average_score` computation (-0.5)
- `bob_score` variables is not defined, initialized, and used in `average_score` computation (-0.5)
- `chang_score` variables is not defined, initialized, and used in `average_score` computation (-0.5)
- `divya_score` variables is not defined, initialized, and used in `average_score` computation (-0.5)
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