From 46cc746b1e3d89b95e3354e53a99c98a96b0b18c Mon Sep 17 00:00:00 2001 From: Linah Khayri Date: Sun, 29 Dec 2024 18:24:39 +0300 Subject: [PATCH 1/9] cheat sheets for python and vscode --- notes/cheatsheets.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 notes/cheatsheets.md diff --git a/notes/cheatsheets.md b/notes/cheatsheets.md new file mode 100644 index 000000000..6cde57514 --- /dev/null +++ b/notes/cheatsheets.md @@ -0,0 +1,10 @@ +# Cheat Sheets that can help 📚 + +--- + +## These **cheat sheets** cover key topics and best practices that we might encounter in our work + +- [VS Code Cheat Sheet](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf) ⚡ +- [Python Cheat Sheet](https://kieranholland.com/best-python-cheat-sheet/) 🐍 + +### Feel free to add yours ➕📝 From 974d9f33bab8bd00a3e290456c23b2d6c75c8ef7 Mon Sep 17 00:00:00 2001 From: robiel0143 Date: Sun, 29 Dec 2024 22:17:17 +0300 Subject: [PATCH 2/9] to prepare the notes --- notes/README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/notes/README.md b/notes/README.md index 17e0f0ded..30c0b4e90 100644 --- a/notes/README.md +++ b/notes/README.md @@ -1 +1,60 @@ # Notes + +## Meeting Notes and Task Assignments + +### First Meeting + +- **Introductions**: + - Members introduced themselves and shared their locations. +- **Discussion**: + - Assignment to practice document formatting. + - Task: Comment on a single topic — **Preparing Group Norms**. +- **Outcome**: + - Gained familiarity with document file commenting using instructions from Evan. + +--- + +### Transition to GitHub Format + +- **Reason**: + - After mastering the document file format, decided to transition to GitHub for task management and creating branches to represent specific tasks. +- **Second Meeting**: + - Discussed specific tasks and group assignments. + +--- + +### Task Assignments and Reviews + +1. **Group Norms**: + - **Task Members**: Abel and Banchiamlak + - Modified the file and pushed it to GitHub. + - **Reviewers**: Gai and Yonatan + +2. **Communication File**: + - **Task Members**: Robel and Zeinab + - Prepared the file and submitted it for review. + - **Reviewers**: Viktoriya and Mohammed + +3. **Learning Objectives**: + - **Task Members**: Viktoriya and Mohammed + - Prepared the file and marked it as done on the project table. + - **Reviewers**: Linah and Khusro + +4. **Retrospective Task**: + - **Task Members**: Gai and Yonatan + - Waited for all other tasks to complete before preparing the file. + - **Reviewers**: Abel and Banchiamlak + +--- + +### Post-Task Activities + +- Played with other files, including the **README** file. + +--- + +### Future Plans + +- **Scheduling**: + - Plan tasks for the upcoming week. + - Prepare a **solutions schedule** for future assignments. From 4d35f42cf1424959ee1d1383e2bdbdccf78e3b63 Mon Sep 17 00:00:00 2001 From: Viktoriya Haiduk Date: Mon, 30 Dec 2024 12:58:54 +0200 Subject: [PATCH 3/9] Added sorting task and unit tests --- solutions/sort_numbers.py | 40 ++++++++++++++++++++++++++++ solutions/tests/test_sort_numbers.py | 21 +++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 solutions/sort_numbers.py create mode 100644 solutions/tests/test_sort_numbers.py diff --git a/solutions/sort_numbers.py b/solutions/sort_numbers.py new file mode 100644 index 000000000..23fe4e5df --- /dev/null +++ b/solutions/sort_numbers.py @@ -0,0 +1,40 @@ +def sort_numbers(numbers): + """ + Sorts a list of numbers. + + Parameters: + numbers (list): List of numbers. + + Returns: + list: Sorted list of numbers or a message if sorting isn't possible. + + Examples: + >>> sort_numbers([3, 1, 2]) + [1, 2, 3] + >>> sort_numbers([4.5, 15.4, 6, 7, 2]) + [2, 4.5, 6, 7, 15.4] + >>> sort_numbers([3.14159, 1.618, 2.718]) + [1.618, 2.718, 3.14159] + >>> sort_numbers([4.5, 15.4, 6, 7, 2, 'text']) + "Isn't possible to sort" + >>> sort_numbers([1.1, 2, 3.5, 4.0]) + [1.1, 2, 3.5, 4.0] + """ + + if all(isinstance(num, (int, float)) for num in numbers): + return sorted(numbers) + else: + return "Isn't possible to sort" + +# Console interaction +def console_sort(): + input_numbers = input("Enter numbers separated by commas: ") + try: + numbers = [float(num) for num in input_numbers.split(',')] + result = sort_numbers(numbers) + print(result) + except ValueError: + print("Invalid input. Please enter numbers only.") + +if __name__ == "__main__": + console_sort() diff --git a/solutions/tests/test_sort_numbers.py b/solutions/tests/test_sort_numbers.py new file mode 100644 index 000000000..01dbf6e10 --- /dev/null +++ b/solutions/tests/test_sort_numbers.py @@ -0,0 +1,21 @@ +import unittest +from your_sorting_function import sort_numbers # Replace with the actual function name + +class TestSortNumbers(unittest.TestCase): + def test_sorted_numbers(self): + self.assertEqual(sort_numbers([4, 1, 3, 2]), [1, 2, 3, 4]) + + def test_floats(self): + self.assertEqual(sort_numbers([4.5, 2.3, 1.7, 3.9]), [1.7, 2.3, 3.9, 4.5]) + + def test_mixed_numbers(self): + self.assertEqual(sort_numbers([4, 2.5, 3, 1.2]), [1.2, 2.5, 3, 4]) + + def test_invalid_input(self): + self.assertEqual(sort_numbers(['a', None, 3]), "Isn't possible to sort") + + def test_empty_list(self): + self.assertEqual(sort_numbers([]), "Isn't possible to sort") + +if __name__ == '__main__': + unittest.main() From 5beb38cb97733bf894f8a7597fb3390aed70ebb8 Mon Sep 17 00:00:00 2001 From: Viktoriya Haiduk Date: Mon, 30 Dec 2024 13:27:33 +0200 Subject: [PATCH 4/9] Added sorting task and unit tests-fixing --- .vscode/settings.json | 4 ++-- solutions/sort_numbers.py | 4 +++- solutions/tests/test_sort_numbers.py | 15 +++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bbda5188d..252022b48 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -119,8 +119,8 @@ "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll.ruff": true, - "source.organizeImports.ruff": true + "source.fixAll.ruff": "explicit", + "source.organizeImports.ruff": "explicit" } } } diff --git a/solutions/sort_numbers.py b/solutions/sort_numbers.py index 23fe4e5df..16172ec7f 100644 --- a/solutions/sort_numbers.py +++ b/solutions/sort_numbers.py @@ -26,15 +26,17 @@ def sort_numbers(numbers): else: return "Isn't possible to sort" + # Console interaction def console_sort(): input_numbers = input("Enter numbers separated by commas: ") try: - numbers = [float(num) for num in input_numbers.split(',')] + numbers = [float(num) for num in input_numbers.split(",")] result = sort_numbers(numbers) print(result) except ValueError: print("Invalid input. Please enter numbers only.") + if __name__ == "__main__": console_sort() diff --git a/solutions/tests/test_sort_numbers.py b/solutions/tests/test_sort_numbers.py index 01dbf6e10..847c0c27b 100644 --- a/solutions/tests/test_sort_numbers.py +++ b/solutions/tests/test_sort_numbers.py @@ -1,21 +1,24 @@ import unittest + from your_sorting_function import sort_numbers # Replace with the actual function name + class TestSortNumbers(unittest.TestCase): def test_sorted_numbers(self): self.assertEqual(sort_numbers([4, 1, 3, 2]), [1, 2, 3, 4]) - + def test_floats(self): self.assertEqual(sort_numbers([4.5, 2.3, 1.7, 3.9]), [1.7, 2.3, 3.9, 4.5]) - + def test_mixed_numbers(self): self.assertEqual(sort_numbers([4, 2.5, 3, 1.2]), [1.2, 2.5, 3, 4]) - + def test_invalid_input(self): - self.assertEqual(sort_numbers(['a', None, 3]), "Isn't possible to sort") - + self.assertEqual(sort_numbers(["a", None, 3]), "Isn't possible to sort") + def test_empty_list(self): self.assertEqual(sort_numbers([]), "Isn't possible to sort") -if __name__ == '__main__': + +if __name__ == "__main__": unittest.main() From 08061faff193a9617fe9dc3a26b13693766b2277 Mon Sep 17 00:00:00 2001 From: Viktoriya Haiduk Date: Mon, 30 Dec 2024 13:59:31 +0200 Subject: [PATCH 5/9] Added sorting task and unit test - fixing-step 2 --- solutions/sort_numbers.py | 18 +++--------------- solutions/tests/test_sort_numbers.py | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/solutions/sort_numbers.py b/solutions/sort_numbers.py index 16172ec7f..0e61e7e9c 100644 --- a/solutions/sort_numbers.py +++ b/solutions/sort_numbers.py @@ -21,22 +21,10 @@ def sort_numbers(numbers): [1.1, 2, 3.5, 4.0] """ + if not numbers: + return "Isn't possible to sort" + if all(isinstance(num, (int, float)) for num in numbers): return sorted(numbers) else: return "Isn't possible to sort" - - -# Console interaction -def console_sort(): - input_numbers = input("Enter numbers separated by commas: ") - try: - numbers = [float(num) for num in input_numbers.split(",")] - result = sort_numbers(numbers) - print(result) - except ValueError: - print("Invalid input. Please enter numbers only.") - - -if __name__ == "__main__": - console_sort() diff --git a/solutions/tests/test_sort_numbers.py b/solutions/tests/test_sort_numbers.py index 847c0c27b..18bbb41ff 100644 --- a/solutions/tests/test_sort_numbers.py +++ b/solutions/tests/test_sort_numbers.py @@ -1,6 +1,6 @@ import unittest -from your_sorting_function import sort_numbers # Replace with the actual function name +from solutions.sort_numbers import sort_numbers class TestSortNumbers(unittest.TestCase): From f2fde4b83e1dd8a0cd7ba2ffea40f6525219bf37 Mon Sep 17 00:00:00 2001 From: Viktoriya Haiduk Date: Mon, 30 Dec 2024 17:32:17 +0200 Subject: [PATCH 6/9] fixing due to Mohamed suggestions --- solutions/sort_numbers.py | 44 ++++++++++++++++------------ solutions/tests/test_sort_numbers.py | 15 ++++++++-- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/solutions/sort_numbers.py b/solutions/sort_numbers.py index 0e61e7e9c..59429bd10 100644 --- a/solutions/sort_numbers.py +++ b/solutions/sort_numbers.py @@ -1,30 +1,38 @@ -def sort_numbers(numbers): +""" +Module for sorting a list of numbers. + +Author: Viktoriya Haiduk +""" + + +def sort_numbers(numbers: list) -> list: """ Sorts a list of numbers. Parameters: - numbers (list): List of numbers. + numbers (list): A list of numbers to be sorted. + - May contain integers or floats. + - Must not contain non-numeric values. Returns: - list: Sorted list of numbers or a message if sorting isn't possible. + list: Sorted list of numbers in ascending order. + Raises ValueError if the list is empty or contains non-numeric values. Examples: - >>> sort_numbers([3, 1, 2]) - [1, 2, 3] - >>> sort_numbers([4.5, 15.4, 6, 7, 2]) - [2, 4.5, 6, 7, 15.4] - >>> sort_numbers([3.14159, 1.618, 2.718]) - [1.618, 2.718, 3.14159] - >>> sort_numbers([4.5, 15.4, 6, 7, 2, 'text']) - "Isn't possible to sort" - >>> sort_numbers([1.1, 2, 3.5, 4.0]) - [1.1, 2, 3.5, 4.0] + >>> sort_numbers([3, 1, 2]) + [1, 2, 3] + >>> sort_numbers([4.5, 15.4, 6, 7, 2]) + [2, 4.5, 6, 7, 15.4] + >>> sort_numbers([3.14159, 1.618, 2.718]) + [1.618, 2.718, 3.14159] """ + if not isinstance(numbers, list): + raise ValueError("Input must be a list.") if not numbers: - return "Isn't possible to sort" + raise ValueError("The list is empty. Please provide numbers to sort.") + + if not all(isinstance(num, (int, float)) for num in numbers): + raise ValueError("The list contains non-numeric values.") - if all(isinstance(num, (int, float)) for num in numbers): - return sorted(numbers) - else: - return "Isn't possible to sort" + return sorted(numbers) diff --git a/solutions/tests/test_sort_numbers.py b/solutions/tests/test_sort_numbers.py index 18bbb41ff..221319940 100644 --- a/solutions/tests/test_sort_numbers.py +++ b/solutions/tests/test_sort_numbers.py @@ -14,10 +14,21 @@ def test_mixed_numbers(self): self.assertEqual(sort_numbers([4, 2.5, 3, 1.2]), [1.2, 2.5, 3, 4]) def test_invalid_input(self): - self.assertEqual(sort_numbers(["a", None, 3]), "Isn't possible to sort") + with self.assertRaises(ValueError) as context: + sort_numbers(["a", None, 3]) + self.assertEqual( + str(context.exception), "The list contains non-numeric values." + ) def test_empty_list(self): - self.assertEqual(sort_numbers([]), "Isn't possible to sort") + with self.assertRaises(ValueError) as context: + sort_numbers([]) + self.assertEqual( + str(context.exception), "The list is empty. Please provide numbers to sort." + ) + + def test_negative_numbers(self): + self.assertEqual(sort_numbers([-3, -1, -4, -2]), [-4, -3, -2, -1]) if __name__ == "__main__": From 95bfba07d04808a9510b3a1e021127df9a6a3533 Mon Sep 17 00:00:00 2001 From: Viktoriya Haiduk Date: Mon, 30 Dec 2024 22:38:34 +0200 Subject: [PATCH 7/9] adding author and date --- solutions/sort_numbers.py | 14 +++++++++----- solutions/tests/test_sort_numbers.py | 9 +++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/solutions/sort_numbers.py b/solutions/sort_numbers.py index 59429bd10..9ab539cfb 100644 --- a/solutions/sort_numbers.py +++ b/solutions/sort_numbers.py @@ -1,7 +1,11 @@ """ -Module for sorting a list of numbers. +A module for sorting a list of numbers. -Author: Viktoriya Haiduk +Module contents: sorted list of numbers + +Created on 2024-12-30 + +@author: Viktoriya Haiduk """ @@ -14,9 +18,9 @@ def sort_numbers(numbers: list) -> list: - May contain integers or floats. - Must not contain non-numeric values. - Returns: - list: Sorted list of numbers in ascending order. - Raises ValueError if the list is empty or contains non-numeric values. + Returns -> list: Sorted list of numbers in ascending order. + + Raises: ValueError if the list is empty or contains non-numeric values. Examples: >>> sort_numbers([3, 1, 2]) diff --git a/solutions/tests/test_sort_numbers.py b/solutions/tests/test_sort_numbers.py index 221319940..79f93fb91 100644 --- a/solutions/tests/test_sort_numbers.py +++ b/solutions/tests/test_sort_numbers.py @@ -1,3 +1,12 @@ +""" +Test module for sort_numbers function. + +Contains tests for testing sort_numbers function. + +Created on 2024-12-30 +Author: Viktoriya Haiduk +""" + import unittest from solutions.sort_numbers import sort_numbers From cd062fe86e66715dab7a8e84d54170f78a3a06aa Mon Sep 17 00:00:00 2001 From: colevandersWands <18554853+colevandersWands@users.noreply.github.com> Date: Tue, 31 Dec 2024 00:45:28 -0500 Subject: [PATCH 8/9] no commented code, no print statements --- .github/PULL_REQUEST_TEMPLATE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 330a04cbc..a211d8686 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -82,5 +82,7 @@ about: A template PR for code review with a checklist - [ ] Variable names are clear and helpful - [ ] The code follows the strategy as simply as possible - [ ] The implementation is as simple as possible given the strategy +- [ ] There are no commented lines of code +- [ ] There are no `print` statements anywhere - [ ] The code includes defensive assertions - [ ] Defensive assertions include as little logic as possible From 5effaf514caab0f6733a46c631b24268e4dd3f9d Mon Sep 17 00:00:00 2001 From: colevandersWands <18554853+colevandersWands@users.noreply.github.com> Date: Tue, 31 Dec 2024 00:46:35 -0500 Subject: [PATCH 9/9] do not call the function in the function file --- .github/PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a211d8686..6e269b4ad 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -55,6 +55,7 @@ about: A template PR for code review with a checklist - [ ] The function's name describes it's behavior - [ ] The function's name matches the file name - [ ] The function has correct type annotations +- [ ] The function is not called in the function file ## Strategy