-
Notifications
You must be signed in to change notification settings - Fork 15
system check assessment #7
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?
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 | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,11 @@ 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 | ||||||||||||||||||||||||||||||||||||||||||
| ticket_string = ticket_string.split("-") | ||||||||||||||||||||||||||||||||||||||||||
| return ticket_string[2] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ticket_string = "FL-JO234-JNB-CPT-2023" | ||||||||||||||||||||||||||||||||||||||||||
| get_departure_airport(ticket_string) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def check_baggage_allowance(ticket_string: str): | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -36,7 +40,20 @@ def check_baggage_allowance(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||
| - For any other code: return "Standard - 0kg" | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||
| ticket_string = ticket_string.split("-") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ticket_string[0] == "EC": | ||||||||||||||||||||||||||||||||||||||||||
| return "Economy - 20kg" | ||||||||||||||||||||||||||||||||||||||||||
| elif ticket_string[0] == "BS": | ||||||||||||||||||||||||||||||||||||||||||
| return "Business - 40kg" | ||||||||||||||||||||||||||||||||||||||||||
| elif ticket_string[0] == "FL": | ||||||||||||||||||||||||||||||||||||||||||
| return "First Class - 60kg" | ||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||
| return "Standard - 0kg" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ticket_string = "FL-JO234-JNB-CPT-2023" | ||||||||||||||||||||||||||||||||||||||||||
| check_baggage_allowance(ticket_string) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+56
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def validate_flight_number(ticket_string: str): | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -50,7 +67,25 @@ def validate_flight_number(ticket_string: str): | |||||||||||||||||||||||||||||||||||||||||
| - If the numeric part cannot be converted to a number, return "Invalid Flight" | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
| # TODO: Write your code here | ||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||
| ticket_string = ticket_string.split("-") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ticket = ticket_string[1] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ticket_num = ticket[-1] | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if not ticket_num.isdigit(): | ||||||||||||||||||||||||||||||||||||||||||
| return "Invalid Flight" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if int(ticket_num)%2 == 0: | ||||||||||||||||||||||||||||||||||||||||||
| return "Valid - Northbound" | ||||||||||||||||||||||||||||||||||||||||||
| elif int(ticket_num)%2 != 0: | ||||||||||||||||||||||||||||||||||||||||||
| return "Valid - Southbound" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+84
|
||||||||||||||||||||||||||||||||||||||||||
| ticket = ticket_string[1] | |
| ticket_num = ticket[-1] | |
| if not ticket_num.isdigit(): | |
| return "Invalid Flight" | |
| if int(ticket_num)%2 == 0: | |
| return "Valid - Northbound" | |
| elif int(ticket_num)%2 != 0: | |
| return "Valid - Southbound" | |
| ticket = ticket_string[1] | |
| ticket_num = ticket[-1] | |
| if not ticket_num.isdigit(): | |
| return "Invalid Flight" | |
| if int(ticket_num)%2 == 0: | |
| return "Valid - Northbound" | |
| elif int(ticket_num)%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.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
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.
Remove trailing whitespace at the end of this line.
| return True | |
| 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.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
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.
Test is always true, because of this condition.
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.
Remove this unnecessary blank line at the end of the file.
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.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.
| reactor_status(-1, 50) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import unittest | ||
| import os | ||
| from system_check import reactor_status | ||
|
|
||
| class TestReactor(unittest.TestCase): | ||
|
|
||
| def test_00_tdd_file_exists(self): | ||
| print("\nGrading Pre-Check: Looking for student test file...") | ||
| file_exists = os.path.exists("test_reactor.py") | ||
|
|
||
| self.assertTrue( | ||
| file_exists, | ||
| msg="❌ FAILED: 'test_reactor.py' was not found. Did you create the file?" | ||
| ) | ||
| print("✅ FOUND: 'test_reactor.py' exists.") | ||
|
|
||
| def test_q5_reactor_status(self): | ||
| print("Grading Q5: Reactor Logic...") | ||
| self.assertEqual(reactor_status(-1, 50), "Sensor Error") | ||
| self.assertEqual(reactor_status(500, -10), "Sensor Error") | ||
| self.assertEqual(reactor_status(2500, 10), "CRITICAL") | ||
| self.assertEqual(reactor_status(500, 600), "CRITICAL") | ||
| self.assertEqual(reactor_status(1500, 200), "WARNING") | ||
| self.assertEqual(reactor_status(1000, 200), "WARNING") | ||
| self.assertEqual(reactor_status(400, 50), "Maintenance Mode") | ||
| self.assertEqual(reactor_status(800, 50), "Normal Operation") | ||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main(failfast=True, verbosity=0) |
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.
Remove this test/debug code. Function definitions in a module should not include standalone function calls at the module level, as they execute on import and can cause unexpected side effects.