|
| 1 | +# 🔴 CRITICAL BUGS - Priority: HIGH |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +## Issue #1: Prime Number Checker Has Inverted Logic |
| 6 | + |
| 7 | +### Title |
| 8 | +[BUG]: Prime number checker returns incorrect results |
| 9 | + |
| 10 | +### Description |
| 11 | + |
| 12 | +**What:** The prime number checking algorithm in `basics/03_control_flow/02_check_prime.py` has a critical logic error that inverts the final result. |
| 13 | + |
| 14 | +**Why it matters:** Students learning from this example will be taught incorrect logic. The program returns `False` for prime numbers and `True` for non-prime numbers. |
| 15 | + |
| 16 | +**Where:** `basics/03_control_flow/02_check_prime.py`, lines 13-16 |
| 17 | + |
| 18 | +**Current behavior:** |
| 19 | +```python |
| 20 | +# Lines 13-16 - Logic is inverted |
| 21 | +if(prime): |
| 22 | + prime = False # Bug: This makes primes return False! |
| 23 | +else: |
| 24 | + prime = True # Bug: This makes non-primes return True! |
| 25 | +``` |
| 26 | + |
| 27 | +**Expected behavior:** |
| 28 | +- Input `7` should return `True` (is prime) |
| 29 | +- Input `10` should return `False` (not prime) |
| 30 | + |
| 31 | +**Suggested approach:** |
| 32 | +Remove lines 13-16 entirely. The logic before this already correctly sets the `prime` variable. |
| 33 | + |
| 34 | +**Acceptance criteria:** |
| 35 | +- [ ] Remove the inverted logic block (lines 13-16) |
| 36 | +- [ ] Test with prime numbers: 2, 3, 5, 7, 11 → should return `True` |
| 37 | +- [ ] Test with non-prime numbers: 4, 6, 8, 9, 10 → should return `False` |
| 38 | +- [ ] Test edge cases: 0, 1, negative numbers → should return `False` |
| 39 | + |
| 40 | +**Labels:** `bug`, `priority: high`, `good first issue` |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Issue #2: Function Named 'sum' Performs Division |
| 45 | + |
| 46 | +### Title |
| 47 | +[BUG]: Function `sum()` in error handling example performs division instead of addition |
| 48 | + |
| 49 | +### Description |
| 50 | + |
| 51 | +**What:** In `basics/09_error_handling/01_try_except.py`, the function named `sum` actually performs division, which is misleading and confusing. |
| 52 | + |
| 53 | +**Why it matters:** This violates basic naming conventions and will confuse beginners learning about functions and error handling. |
| 54 | + |
| 55 | +**Where:** `basics/09_error_handling/01_try_except.py`, lines 1-3 |
| 56 | + |
| 57 | +**Current behavior:** |
| 58 | +```python |
| 59 | +def sum(a: int, b: int) -> int: # Name suggests addition |
| 60 | + result = a / b # But performs division! |
| 61 | + return result |
| 62 | +``` |
| 63 | + |
| 64 | +**Expected behavior:** Function name should match its operation. |
| 65 | + |
| 66 | +**Suggested approach:** |
| 67 | +Rename the function to `divide` and update the type hint to return `float`: |
| 68 | + |
| 69 | +```python |
| 70 | +def divide(a: int, b: int) -> float: |
| 71 | + result = a / b |
| 72 | + return result |
| 73 | +``` |
| 74 | + |
| 75 | +**Acceptance criteria:** |
| 76 | +- [ ] Rename function from `sum` to `divide` |
| 77 | +- [ ] Update return type hint to `float` |
| 78 | +- [ ] Update function call on line 16 |
| 79 | +- [ ] Add docstring explaining the function |
| 80 | + |
| 81 | +**Labels:** `bug`, `refactor`, `good first issue`, `priority: medium` |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## Issue #3: No Input Validation in Guess Number Game |
| 86 | + |
| 87 | +### Title |
| 88 | +[BUG]: Guess number game crashes on non-integer input |
| 89 | + |
| 90 | +### Description |
| 91 | + |
| 92 | +**What:** The guess number game (`basics/11_projects/01_guess_number.py`) has no try/except handling for invalid input, causing crashes when users enter non-integer values. |
| 93 | + |
| 94 | +**Why it matters:** Poor user experience - the game crashes instead of prompting for valid input. |
| 95 | + |
| 96 | +**Where:** `basics/11_projects/01_guess_number.py`, line 10 |
| 97 | + |
| 98 | +**Current behavior:** |
| 99 | +```python |
| 100 | +user_input = int(input(f"Guess the Number: ")) # Crashes on "abc" |
| 101 | +``` |
| 102 | + |
| 103 | +**Expected behavior:** Should catch `ValueError` and prompt user to enter a valid number. |
| 104 | + |
| 105 | +**Suggested approach:** |
| 106 | +Wrap the input in a try/except block: |
| 107 | + |
| 108 | +```python |
| 109 | +try: |
| 110 | + user_input = int(input(f"Guess the Number: ")) |
| 111 | +except ValueError: |
| 112 | + print("Please enter a valid number!") |
| 113 | + continue |
| 114 | +``` |
| 115 | + |
| 116 | +**Acceptance criteria:** |
| 117 | +- [ ] Add ValueError handling around int() conversion |
| 118 | +- [ ] Display friendly error message on invalid input |
| 119 | +- [ ] Allow user to try again without crashing |
| 120 | +- [ ] Test with inputs: "abc", "12.5", "", special characters |
| 121 | + |
| 122 | +**Labels:** `bug`, `enhancement`, `good first issue` |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## Issue #4: Rock Paper Scissors Has No Input Validation |
| 127 | + |
| 128 | +### Title |
| 129 | +[BUG]: Rock paper scissors game crashes on invalid input |
| 130 | + |
| 131 | +### Description |
| 132 | + |
| 133 | +**What:** The rock-paper-scissors game (`basics/11_projects/03_rock_paper_scissors.py`) doesn't validate user input before using `.upper()` and doesn't handle invalid choices. |
| 134 | + |
| 135 | +**Why it matters:** Game returns "Something Wents Wrong" for any input other than R, P, S. |
| 136 | + |
| 137 | +**Where:** `basics/11_projects/03_rock_paper_scissors.py`, lines 10-26 |
| 138 | + |
| 139 | +**Suggested approach:** |
| 140 | +Add input validation loop: |
| 141 | + |
| 142 | +```python |
| 143 | +while True: |
| 144 | + userinput = input("R - Rock\nP - Paper\nS - Scissor\nChoose: ").upper() |
| 145 | + if userinput in ["R", "P", "S"]: |
| 146 | + break |
| 147 | + print("Invalid choice! Please choose R, P, or S.") |
| 148 | +``` |
| 149 | + |
| 150 | +**Acceptance criteria:** |
| 151 | +- [ ] Validate input is one of R, P, S |
| 152 | +- [ ] Loop until valid input is received |
| 153 | +- [ ] Fix typo: "Wents" → "Went" |
| 154 | +- [ ] Add case-insensitive handling |
| 155 | + |
| 156 | +**Labels:** `bug`, `enhancement`, `good first issue` |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## Issue #5: File Handling Examples Use Non-Existent Files |
| 161 | + |
| 162 | +### Title |
| 163 | +[BUG]: File handling examples reference files that don't exist |
| 164 | + |
| 165 | +### Description |
| 166 | + |
| 167 | +**What:** Multiple file handling examples reference files like `poems.txt`, `newfile.txt` without checking if they exist first or creating them. |
| 168 | + |
| 169 | +**Why it matters:** Examples fail when run, confusing beginners. |
| 170 | + |
| 171 | +**Where:** |
| 172 | +- `basics/07_file_handling/01_file_handling_basics.py` - `newfile.txt` |
| 173 | +- `basics/07_file_handling/07_file_find_word.py` - `poems.txt` |
| 174 | + |
| 175 | +**Suggested approach:** |
| 176 | +Add file existence check and creation: |
| 177 | + |
| 178 | +```python |
| 179 | +import os |
| 180 | + |
| 181 | +filename = "poems.txt" |
| 182 | +if not os.path.exists(filename): |
| 183 | + with open(filename, "w") as f: |
| 184 | + f.write("Twinkle, twinkle, little star...") |
| 185 | +``` |
| 186 | + |
| 187 | +**Acceptance criteria:** |
| 188 | +- [ ] Add os.path.exists() checks before reading |
| 189 | +- [ ] Create sample files if they don't exist |
| 190 | +- [ ] Add comment explaining the check |
| 191 | +- [ ] Test on fresh clone (no existing files) |
| 192 | + |
| 193 | +**Labels:** `bug`, `enhancement`, `good first issue` |
| 194 | + |
| 195 | +--- |
0 commit comments