Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/system_check.cpython-312.pyc
Binary file not shown.
70 changes: 65 additions & 5 deletions system_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +24 to +25
Copy link

Copilot AI Nov 28, 2025

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 uses AI. Check for mistakes.

def check_baggage_allowance(ticket_string: str):
"""
Expand All @@ -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
Copy link

Copilot AI Nov 28, 2025

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 uses AI. Check for mistakes.

def validate_flight_number(ticket_string: str):
"""
Expand All @@ -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]
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks the last character of the flight number, not the entire numeric portion. According to the docstring (line 62), you need to extract "the number portion (e.g., 234)" from "JO234". You should extract all trailing digits from the flight number string, not just the last character. For example, for "JO234", you need to extract "234" and check if it's even/odd, not just "4".

Copilot uses AI. Check for mistakes.

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
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary blank line. This creates inconsistent spacing in the function body.

Suggested change
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 uses AI. Check for mistakes.
ticket_string = "FL-JOABC-JNB-CPT"


validate_flight_number(ticket_string)
Comment on lines +85 to +88
Copy link

Copilot AI Nov 28, 2025

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 uses AI. Check for mistakes.


# ==========================================
Expand All @@ -72,7 +107,20 @@ def is_leap_year(year: int):
Return True or False (Boolean).
"""
# TODO: Write your code here
pass
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
return True
else:
return False
else:
return True
Copy link

Copilot AI Nov 28, 2025

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.

Suggested change
return True
return True

Copilot uses AI. Check for mistakes.
else:
return False

year = 2000

is_leap_year(year)
Comment on lines +121 to +123
Copy link

Copilot AI Nov 28, 2025

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 uses AI. Check for mistakes.


# ==========================================
Expand Down Expand Up @@ -105,4 +153,16 @@ def reactor_status(temp: int, radiation: int):
- For all other cases: return "Normal Operation"
"""
# TODO: Write your code here
pass
if temp < 0 or radiation < 0:
return "Sensor Error"
elif temp > 2000 or radiation > 500:
return "CRITICAL"
elif 1000 <= temp <= 2000 and radiation > 100:
Copy link

Copilot AI Nov 28, 2025

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 uses AI. Check for mistakes.
return "WARNING"
elif temp < 500:
return "Maintenance Mode"
else:
return "Normal Operation"


Copy link

Copilot AI Nov 28, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.
reactor_status(-1, 50)
Copy link

Copilot AI Nov 28, 2025

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.

Suggested change
reactor_status(-1, 50)

Copilot uses AI. Check for mistakes.
29 changes: 29 additions & 0 deletions test_reactor.py
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)