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.
38 changes: 38 additions & 0 deletions system_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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
splitted_ticket = ticket_string.split("-")
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.

The ticket string is split multiple times across different functions (lines 21, 41, 64). Consider adding input validation and error handling for the split operation. If the ticket string doesn't contain the expected number of hyphens, the code will raise an IndexError. This would improve robustness.

Copilot uses AI. Check for mistakes.
return splitted_ticket[2]
pass
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.

Unreachable code: the pass statement on line 23 will never execute because the function returns on line 22. Remove this line to clean up the code.

Copilot uses AI. Check for mistakes.

def check_baggage_allowance(ticket_string: str):
Expand All @@ -36,6 +38,15 @@ def check_baggage_allowance(ticket_string: str):
- For any other code: return "Standard - 0kg"
"""
# TODO: Write your code here
splitted_ticket = ticket_string.split("-")
cl = splitted_ticket[0]
if cl == "EC":
return "Economy - 20kg"
elif cl == "BS":
return "Business - 40kg"
elif cl == "FL":
Comment on lines +42 to +47
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.

The variable name cl is too abbreviated and unclear. Consider using a more descriptive name like flight_class or class_code to improve code readability.

Suggested change
cl = splitted_ticket[0]
if cl == "EC":
return "Economy - 20kg"
elif cl == "BS":
return "Business - 40kg"
elif cl == "FL":
flight_class = splitted_ticket[0]
if flight_class == "EC":
return "Economy - 20kg"
elif flight_class == "BS":
return "Business - 40kg"
elif flight_class == "FL":

Copilot uses AI. Check for mistakes.
return "First Class - 60kg"
return "Standard - 0kg"
pass
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.

Unreachable code: the pass statement on line 50 will never execute because the function returns on line 49. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.

def validate_flight_number(ticket_string: str):
Expand All @@ -50,6 +61,17 @@ 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
splitted_ticket = ticket_string.split("-")
ticket_number = splitted_ticket[1]
t_number = ticket_number[-1]

if t_number.isdigit():
if int(t_number)%2 == 0:
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.

Missing spaces around the modulo and equality operators. According to PEP 8 style guidelines, change int(t_number)%2 == 0 to int(t_number) % 2 == 0 for better readability.

Suggested change
if int(t_number)%2 == 0:
if int(t_number) % 2 == 0:

Copilot uses AI. Check for mistakes.
return "Valid - Northbound"
else:
return "Valid - Southbound"
Comment on lines +66 to +72
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.

The logic only checks the last digit of the flight number (ticket_number[-1]) instead of extracting and checking the entire numeric portion. For example, in "JO234", this code checks if "4" is even/odd, but it should check if "234" is even/odd. Extract the numeric part properly (e.g., using ticket_number[2:] for "JO234") and convert it to an integer before checking.

Suggested change
t_number = ticket_number[-1]
if t_number.isdigit():
if int(t_number)%2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"
# Extract numeric portion from flight number (e.g., "JO234" -> "234")
numeric_part = ''.join(filter(str.isdigit, ticket_number))
if numeric_part:
try:
num = int(numeric_part)
if num % 2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"
except ValueError:
return "Invalid Flight"

Copilot uses AI. Check for mistakes.
else:
return "Invalid Flight"
pass
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.

Unreachable code: the pass statement on line 75 will never execute because the function returns on line 74. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.


Expand All @@ -71,6 +93,13 @@ def is_leap_year(year: int):

Return True or False (Boolean).
"""
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
return True
return False
return True
return False
Comment on lines +96 to +102
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.

Missing spaces around the modulo operator. According to PEP 8 style guidelines, binary operators should have spaces around them. Change year%4 to year % 4, year%100 to year % 100, and year%400 to year % 400 for better readability.

Copilot uses AI. Check for mistakes.
# TODO: Write your code here
pass
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.

Unreachable code: the pass statement on line 104 will never execute because the function returns on lines 96-102. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -105,4 +134,13 @@ def reactor_status(temp: int, radiation: int):
- For all other cases: return "Normal Operation"
"""
# TODO: Write your code here
if temp < 0 or radiation < 0:
return "Sensor Error"
if temp > 2000 or radiation > 500:
return "CRITICAL"
if (temp >= 1000 and 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.

Suggested change
if (temp >= 1000 and temp <= 2000) and radiation > 100:
if temp >= 1000 and radiation > 100:

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

Unreachable code: the pass statement on line 146 will never execute because the function returns on line 145. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.
3 changes: 3 additions & 0 deletions test_reactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class TestReactor:
def __int__(self):
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.

The method name should be __init__ (with two underscores on each side), not __int__. The current name __int__ is a different magic method used for integer conversion, not for initialization.

Suggested change
def __int__(self):
def __init__(self):

Copilot uses AI. Check for mistakes.
pass
Comment on lines +1 to +3
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.

The TestReactor class is empty and doesn't contain any test methods. According to the requirements in system_check.py (lines 117-118), this class should implement TDD tests for the reactor_status function. The class should inherit from unittest.TestCase and include test methods for the various reactor status conditions (Sensor Error, CRITICAL, WARNING, Maintenance Mode, and Normal Operation).

Copilot uses AI. Check for mistakes.