-
Notifications
You must be signed in to change notification settings - Fork 15
pullitt #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
pullitt #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "python.testing.unittestArgs": [ | ||
| "-v", | ||
| "-s", | ||
| ".", | ||
| "-p", | ||
| "test_*.py" | ||
| ], | ||
| "python.testing.pytestEnabled": false, | ||
| "python.testing.unittestEnabled": true | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,9 @@ def get_departure_airport(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Flight Number (JO234) can vary in length. You must find it relative to the hyphens. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a, b, c, d, e = ticket_string.split("-") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(get_departure_airport("FL-JO234-JNB-CPT-2023")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def check_baggage_allowance(ticket_string: str): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -36,7 +38,16 @@ def check_baggage_allowance(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - For any other code: return "Standard - 0kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a, b, c, d = ticket_string.split("-") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a == "EC": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "Economy - 20kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif a == 'BS': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "Business - 40kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif a == 'FL': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "First Class - 60kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "Standard - 0kg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "Standard - 0kg" | |
| return "Standard - 0kg" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed. This print call appears to be leftover from testing/debugging and should not be present in production code.
| print(check_baggage_allowance("EC-JO234-JNB-CPT")) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The elif check for odd numbers is redundant. Since you already check for even numbers with % 2 == 0, the elif int(b[2::]) % 2 != 0 is redundant as it will always be true if the previous condition is false. Simply use else instead.
| elif int(b[2::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| else: | |
| return "Valid - Southbound" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The elif check for odd numbers is redundant. Since you already check for even numbers with % 2 == 0, the elif int(b[1::]) % 2 != 0 is redundant as it will always be true if the previous condition is false. Simply use else instead.
| elif int(b[2::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| else: | |
| return "Valid - Southbound" | |
| # else: | |
| # return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" | |
| # else: | |
| # return "Invalid Flight" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else block is unreachable code. Since the integer modulo 2 will always be either 0 (even) or non-zero (odd), this else condition can never be reached. Remove these unreachable lines.
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else block is unreachable code. Since the integer modulo 2 will always be either 0 (even) or non-zero (odd), this else condition can never be reached. Remove these unreachable lines.
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded special case check for "JOABC" is fragile. This check should either be generalized to handle any non-numeric flight number or moved to a try-except block around the int() conversion to properly catch ValueError exceptions.
| if b == "JOABC": | |
| return "Invalid Flight" | |
| if b.startswith("JO"): | |
| if int(b[2::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[2::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| num_part = None | |
| if b.startswith("JO"): | |
| num_part = b[2:] | |
| elif b.startswith("A"): | |
| num_part = b[1:] | |
| else: | |
| return "Invalid Flight" | |
| try: | |
| num = int(num_part) | |
| if num % 2 == 0: | |
| return "Valid - Northbound" | |
| else: | |
| return "Valid - Southbound" | |
| except ValueError: | |
| return "Invalid Flight" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for ValueError when converting flight number to integer. If the numeric part of the flight number cannot be converted (e.g., contains letters after the prefix), the int() calls on lines 68, 70, 75, and 77 will raise an unhandled exception. Wrap these conversions in a try-except block to catch ValueError and return "Invalid Flight" as specified in the docstring.
| if int(b[2::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[2::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| if int(b[1::]) % 2 == 0: | |
| return "Valid - Northbound" | |
| elif int(b[1::]) % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| try: | |
| num = int(b[2:]) | |
| except ValueError: | |
| return "Invalid Flight" | |
| if num % 2 == 0: | |
| return "Valid - Northbound" | |
| elif num % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" | |
| elif b.startswith("A"): | |
| try: | |
| num = int(b[1:]) | |
| except ValueError: | |
| return "Invalid Flight" | |
| if num % 2 == 0: | |
| return "Valid - Northbound" | |
| elif num % 2 != 0: | |
| return "Valid - Southbound" | |
| else: | |
| return "Invalid Flight" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed. This print call appears to be leftover from testing/debugging and should not be present in production code.
| print(validate_flight_number("FL-JOABC-JNB-CPT")) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect leap year logic for years divisible by 100. According to the leap year rules, if a year is divisible by 100 but not by 400, it should NOT be a leap year. This line should return False, not True. For example, 1900 is divisible by 100 but not by 400, so it's not a leap year.
| if year % 400 == 0: | |
| return True | |
| elif year % 100 == 0: | |
| return True | |
| elif year % 4 == 0: | |
| return True | |
| if year % 4 != 0: | |
| return False | |
| elif year % 100 != 0: | |
| return True | |
| elif year % 400 == 0: | |
| return True |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed. This print call appears to be leftover from testing/debugging and should not be present in production code.
| print(is_leap_year(2000)) |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition temp <= 0 or radiation <= 0 is incorrect according to the specification in the docstring. The requirement states "If temp OR radiation is less than 0", which means strictly less than, not less than or equal to. Zero values should be considered valid sensor readings. Change to temp < 0 or radiation < 0.
| if temp <= 0 or radiation <= 0: | |
| if temp < 0 or radiation < 0: |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed. This print call appears to be leftover from testing/debugging and should not be present in production code.
| print(reactor_status(1500, 200)) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| import unittest | ||||||
| from system_check import reactor_status | ||||||
|
|
||||||
| class TestReactor(unittest.TestCase): | ||||||
| def testreactor(self): | ||||||
|
||||||
| def testreactor(self): | |
| def test_reactor(self): |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ def test_q4_leap_year(self): | |||||
| print("Grading Q4: Leap Year Logic...") | ||||||
| self.assertTrue(is_leap_year(2024)) | ||||||
| self.assertFalse(is_leap_year(2023)) | ||||||
| self.assertFalse(is_leap_year(1900)) | ||||||
| self.assertTrue(is_leap_year(1900)) | ||||||
|
||||||
| self.assertTrue(is_leap_year(1900)) | |
| self.assertFalse(is_leap_year(1900)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed. This print call appears to be leftover from testing/debugging and should not be present in production code.