# Peer Code Review Guidelines
Before you start, check out [conventionalcomments.org](https://conventionalcomments.org/). It provides guidelines and advice for giving feedback during, among other things, code reviews.
You don't need to give detailed feedback to every part of the code.
For each submission you review, formulate _two_ comments for each of the labels below.
Fill out the template `.md` files provided in the `.zip` you download from TeachCenter.
- issue
- suggestion
- question
- nitpick
- praise
In case you don't find two issues, provide suggestions or questions instead.
Include the line(s) a comment refers to in a code block (see the examples below).
## Examples
All examples refer to the following code snippet, which takes a file containg two numbers separated by a comma per line and outputs what percentage of the second number the first one represents.
```python
try:
f = open("numbers.txt")
for line in f:
a, b = [int(n) for n in line.strip().split(",")]
print(f"{a} is {a / b:.2%} of {b}")
f.close()
except Exception:
print("Something happened")
```
With this `numbers.txt`:
```
32,662
742,973
352,433
50,866
124,925
```
the output looks like this:
```
32 is 4.83% of 662
742 is 76.26% of 973
352 is 81.29% of 433
50 is 5.77% of 866
124 is 13.41% of 925
```
### Example Reviews:
---
```python
except Exception:
print("Something happened")
```
Issue: This combination of a broad `except`-clause and error message will make it difficult to figure out what happened.
---
```python
f = open("numbers.txt")
```
Suggestion: Using a context manager to open this file would make sure it is always closed properly. See [here](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files) for details.
---
```python
a, b = [int(n) for n in line.strip().split(",")]
```
Question: Could the input file contain floats? If so, the `int()` call should be replaced accordingly.
---
```python
a, b = [int(n) for n in line.strip().split(",")]
```
Nitpick: Turning this list comprehension into a [generator expression](https://docs.python.org/3/reference/expressions.html#generator-expressions) would be slightly more memory efficient. However, the gain is likely negligible in this case.
---
```python
print(f"{a} is {a / b:.2%} of {b}")
```
Praise: Nice use of the formatting operator to get percentages without explicitly multiplying by 100, didn't know that was possible!
## Questions you can ask (yourself) to find things to provide feedback on:
- Do any tests fail? If yes, what has to be done to make them pass?
- Can parts of the code be improved regarding execution speed and/or memory requirements?
- Is there dead code (i.e. code which is never executed or commented out)?
- Is the code structure (modules, classes, functions) easily comprehensible? Are modules named appropriately? What would you change?
- Do all variable names make sense? Are they helpful to understand what is happening?
- If there are comments, do they explain _what_ is happening (bad) or _why_ something is done (good)? Are they outdated or in sync with the code?
- Is everything (sufficiently) covered by tests?
- Will the tests actually fail when the code is broken?
- Is there something for which a more elegant or more clear solution comes to mind?
- Did a part of the code teach you something new, like a particularly smart way of solving a problem, or a cool language feature?
- Are some solutions "too clever", i.e. they need few lines of code, but take a long time to understand?
- Does the code violate some best practices? Even ruff won't catch everything ;)