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-310.pyc
Binary file not shown.
41 changes: 35 additions & 6 deletions system_check.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
# ==========================================
# SECTION A: DATA PARSING (FLIGHT TICKET SYSTEM)
# ==========================================
Expand All @@ -18,7 +19,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
#my_string = ticket_string[-10:-12]
my_list = []
for i in ticket_string:
if
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.

Incomplete if statement with syntax error. The condition after if is missing, which will cause a SyntaxError when the code is executed.

Suggested change
if
pass

Copilot uses AI. Check for mistakes.
return
Comment on lines +22 to +26
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.

Incomplete return statement. The return statement is missing a value, which will return None instead of the expected departure airport code.

Suggested change
#my_string = ticket_string[-10:-12]
my_list = []
for i in ticket_string:
if
return
# The departure airport code is between the second and third hyphens.
parts = ticket_string.split('-')
if len(parts) >= 4:
return parts[2]
return None

Copilot uses AI. Check for mistakes.

def check_baggage_allowance(ticket_string: str):
"""
Expand All @@ -36,7 +41,14 @@ def check_baggage_allowance(ticket_string: str):
- For any other code: return "Standard - 0kg"
"""
# TODO: Write your code here
pass
if ticket_string[0:2] == "EC":
return f"Economy - 20kg"
elif ticket_string[0:2] == "BS":
return f"Business - 40kg"
elif ticket_string[0:2] == "FL":
return f"First Class - 60kg"
else:
return f"Standard - 0kg"
Comment on lines +45 to +51
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.

[nitpick] Unnecessary f-string usage. The return statements in this function use f-strings without any variable interpolation. Consider using regular strings instead: return "Economy - 20kg" instead of return f"Economy - 20kg".

Suggested change
return f"Economy - 20kg"
elif ticket_string[0:2] == "BS":
return f"Business - 40kg"
elif ticket_string[0:2] == "FL":
return f"First Class - 60kg"
else:
return f"Standard - 0kg"
return "Economy - 20kg"
elif ticket_string[0:2] == "BS":
return "Business - 40kg"
elif ticket_string[0:2] == "FL":
return "First Class - 60kg"
else:
return "Standard - 0kg"

Copilot uses AI. Check for mistakes.

def validate_flight_number(ticket_string: str):
"""
Expand All @@ -50,7 +62,8 @@ 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
#re.search(r"", ticket_string)

Comment on lines +65 to +66
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.

Incomplete function implementation. The validate_flight_number function has no return statement and will return None instead of the expected validation result. The function needs to implement the logic to extract the flight number, check if the numeric part is even or odd, and return the appropriate result.

Copilot uses AI. Check for mistakes.


# ==========================================
Expand All @@ -72,8 +85,15 @@ 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
return False

# ==========================================
# SECTION C: COMPLEX LOGIC & TDD
Expand Down Expand Up @@ -105,4 +125,13 @@ 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 f"Sensor Error"
elif temp > 2000 or radiation > 500:
return f"CRITICAL"
elif (1000 <= temp <= 2000) and radiation > 100:
return f" WARNING"
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.

Extra leading space in the return string. The return value " WARNING" has an extra space at the beginning, which should be "WARNING" to be consistent with other return values and to match the test expectations.

Suggested change
return f" WARNING"
return f"WARNING"

Copilot uses AI. Check for mistakes.
elif temp < 500:
return f"Maintenance Mode"
else:
return f"Normal Operation"
Comment on lines +129 to +137
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.

[nitpick] Unnecessary f-string usage. The return statements in this function use f-strings without any variable interpolation. Consider using regular strings instead for better readability and performance.

Suggested change
return f"Sensor Error"
elif temp > 2000 or radiation > 500:
return f"CRITICAL"
elif (1000 <= temp <= 2000) and radiation > 100:
return f" WARNING"
elif temp < 500:
return f"Maintenance Mode"
else:
return f"Normal Operation"
return "Sensor Error"
elif temp > 2000 or radiation > 500:
return "CRITICAL"
elif (1000 <= temp <= 2000) and radiation > 100:
return " WARNING"
elif temp < 500:
return "Maintenance Mode"
else:
return "Normal Operation"

Copilot uses AI. Check for mistakes.
13 changes: 13 additions & 0 deletions test_reactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest
from system_check import reactor_status

class testReactor(unittest.TestCase):
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.

Class name should follow PascalCase convention. The class name testReactor should be TestReactor to follow Python naming conventions for classes.

Suggested change
class testReactor(unittest.TestCase):
class TestReactor(unittest.TestCase):

Copilot uses AI. Check for mistakes.
def test_reactor(self):
self.assertEqual(reactor_status(-1, 5), "Sensor Error")
self.assertEqual(reactor_status(3000, 600), "CRITICAL")
self.assertEqual(reactor_status(1400, 150), "WARNING")
self.assertEqual(reactor_status(400, 80), "Maintenance Mode")
self.assertEqual(reactor_status(700, 80), "Normal Operation")

if __name__ == "__main__":
unittest.main()