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.
Binary file added __pycache__/test_reactor.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/test_system_check.cpython-312.pyc
Binary file not shown.
59 changes: 50 additions & 9 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
departure_code = ticket_string.split("-")[2]
return departure_code




def check_baggage_allowance(ticket_string: str):
"""
Expand All @@ -36,7 +40,22 @@ def check_baggage_allowance(ticket_string: str):
- For any other code: return "Standard - 0kg"
"""
# TODO: Write your code here
pass
if ticket_string.split("-")[0] == "EC":
baggage_allowance = 20
print("Economy - 20kg")
elif ticket_string.split("-")[0] == "BS":
baggage_allowance = 40
print("Business - 40kg")
elif ticket_string.split("-")[0] == "FL":
baggage_allowance = 60
print("First Class - 60kg")
else:
baggage_allowance = 0
print("Standard - 0kg")
return baggage_allowance
check_baggage_allowance("FL-JO234-JNB-CPT-2023")
Comment on lines +44 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.

The function uses print() statements instead of returning values. According to the docstring, it should return strings like "Economy - 20kg", not print them. Additionally, the return statement on line 55 is inside the else block, so other branches don't return values. The function should return the formatted string in each branch instead of printing.

Suggested change
baggage_allowance = 20
print("Economy - 20kg")
elif ticket_string.split("-")[0] == "BS":
baggage_allowance = 40
print("Business - 40kg")
elif ticket_string.split("-")[0] == "FL":
baggage_allowance = 60
print("First Class - 60kg")
else:
baggage_allowance = 0
print("Standard - 0kg")
return baggage_allowance
check_baggage_allowance("FL-JO234-JNB-CPT-2023")
return "Economy - 20kg"
elif ticket_string.split("-")[0] == "BS":
return "Business - 40kg"
elif ticket_string.split("-")[0] == "FL":
return "First Class - 60kg"
else:
return "Standard - 0kg"
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))

Copilot uses AI. Check for mistakes.
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 function call should be removed. It appears to be debugging/test code left in the production file and will execute every time the module is imported.

Suggested change
check_baggage_allowance("FL-JO234-JNB-CPT-2023")

Copilot uses AI. Check for mistakes.
Comment on lines +43 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.

Variable baggage_allowance is not used.

Suggested change
if ticket_string.split("-")[0] == "EC":
baggage_allowance = 20
print("Economy - 20kg")
elif ticket_string.split("-")[0] == "BS":
baggage_allowance = 40
print("Business - 40kg")
elif ticket_string.split("-")[0] == "FL":
baggage_allowance = 60
print("First Class - 60kg")
else:
baggage_allowance = 0
print("Standard - 0kg")
return baggage_allowance
check_baggage_allowance("FL-JO234-JNB-CPT-2023")
class_code = ticket_string.split("-")[0]
if class_code == "EC":
return "Economy - 20kg"
elif class_code == "BS":
return "Business - 40kg"
elif class_code == "FL":
return "First Class - 60kg"
else:
return "Standard - 0kg"
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))

Copilot uses AI. Check for mistakes.
Comment on lines +44 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.

Variable baggage_allowance is not used.

Suggested change
baggage_allowance = 20
print("Economy - 20kg")
elif ticket_string.split("-")[0] == "BS":
baggage_allowance = 40
print("Business - 40kg")
elif ticket_string.split("-")[0] == "FL":
baggage_allowance = 60
print("First Class - 60kg")
else:
baggage_allowance = 0
print("Standard - 0kg")
return baggage_allowance
check_baggage_allowance("FL-JO234-JNB-CPT-2023")
return "Economy - 20kg"
elif ticket_string.split("-")[0] == "BS":
return "Business - 40kg"
elif ticket_string.split("-")[0] == "FL":
return "First Class - 60kg"
else:
return "Standard - 0kg"
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))

Copilot uses AI. Check for mistakes.
Comment on lines +44 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.

Variable baggage_allowance is not used.

Suggested change
baggage_allowance = 20
print("Economy - 20kg")
elif ticket_string.split("-")[0] == "BS":
baggage_allowance = 40
print("Business - 40kg")
elif ticket_string.split("-")[0] == "FL":
baggage_allowance = 60
print("First Class - 60kg")
else:
baggage_allowance = 0
print("Standard - 0kg")
return baggage_allowance
check_baggage_allowance("FL-JO234-JNB-CPT-2023")
return "Economy - 20kg"
elif ticket_string.split("-")[0] == "BS":
return "Business - 40kg"
elif ticket_string.split("-")[0] == "FL":
return "First Class - 60kg"
else:
return "Standard - 0kg"
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))

Copilot uses AI. Check for mistakes.



def validate_flight_number(ticket_string: str):
"""
Expand All @@ -50,8 +69,23 @@ 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
flight_number = ticket_string.split("-")[1]
print(flight_number)
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 debug print statement should be removed from the production code.

Suggested change
print(flight_number)

Copilot uses AI. Check for mistakes.

for i in flight_number:
direction_val = 0
if i is int:
direction_val += i

if direction_val / 2 == 0 :
print("Valid - Northbound")

elif direction_val / 2 != 0 :
Comment on lines +75 to +83
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 direction_val is being initialized inside the loop on each iteration. It should be initialized once before the loop starts: move this line before line 75.

Suggested change
for i in flight_number:
direction_val = 0
if i is int:
direction_val += i
if direction_val / 2 == 0 :
print("Valid - Northbound")
elif direction_val / 2 != 0 :
direction_val = 0
for i in flight_number:
if i.isdigit():
direction_val += int(i)
if direction_val % 2 == 0 and direction_val != 0:
print("Valid - Northbound")
elif direction_val % 2 != 0:

Copilot uses AI. Check for mistakes.
print("Valid - Southbound")
else:
print("Invalid Flight")
Comment on lines +74 to +86
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 condition direction_val / 2 != 0 is redundant with an else clause. Since the previous if checks for even, the elif for odd is unnecessary. This should be simplified to just else: for the odd case, with the "Invalid Flight" case handled separately (when extraction fails).

Suggested change
for i in flight_number:
direction_val = 0
if i is int:
direction_val += i
if direction_val / 2 == 0 :
print("Valid - Northbound")
elif direction_val / 2 != 0 :
print("Valid - Southbound")
else:
print("Invalid Flight")
# Extract numeric part from flight_number
import re
match = re.search(r'(\d+)', flight_number)
if match:
number = int(match.group(1))
if number % 2 == 0:
print("Valid - Northbound")
else:
print("Valid - Southbound")
else:
print("Invalid Flight")

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +86
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 comparison i is int is incorrect. This checks if i is the int type itself, not if i is an instance of int. It should be if i.isdigit(): for string characters or use isinstance(i, int) if i were an integer. Additionally, direction_val is reset to 0 on each iteration inside the loop, which will cause incorrect behavior.

Suggested change
for i in flight_number:
direction_val = 0
if i is int:
direction_val += i
if direction_val / 2 == 0 :
print("Valid - Northbound")
elif direction_val / 2 != 0 :
print("Valid - Southbound")
else:
print("Invalid Flight")
# Extract numeric part from flight_number (e.g., "JO234" -> "234")
numeric_part = ''.join([c for c in flight_number if c.isdigit()])
if not numeric_part:
print("Invalid Flight")
return
try:
number = int(numeric_part)
except ValueError:
print("Invalid Flight")
return
if number % 2 == 0:
print("Valid - Northbound")
else:
print("Valid - Southbound")

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +86
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 function uses print() statements instead of returning values. According to the docstring, it should return strings like "Valid - Northbound", "Valid - Southbound", or "Invalid Flight", not print them. Replace all print() calls with return statements.

Suggested change
print(flight_number)
for i in flight_number:
direction_val = 0
if i is int:
direction_val += i
if direction_val / 2 == 0 :
print("Valid - Northbound")
elif direction_val / 2 != 0 :
print("Valid - Southbound")
else:
print("Invalid Flight")
# Extract numeric part from flight_number
numeric_part = ''.join(filter(str.isdigit, flight_number))
try:
num = int(numeric_part)
except ValueError:
return "Invalid Flight"
if num % 2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +86
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 condition direction_val / 2 == 0 checks if division equals 0, which would always be False for any positive number. This should use the modulo operator: direction_val % 2 == 0 to check if the number is even.

Suggested change
for i in flight_number:
direction_val = 0
if i is int:
direction_val += i
if direction_val / 2 == 0 :
print("Valid - Northbound")
elif direction_val / 2 != 0 :
print("Valid - Southbound")
else:
print("Invalid Flight")
# Extract numeric part from flight_number
import re
match = re.search(r'\d+', flight_number)
if match:
direction_val = int(match.group())
if direction_val % 2 == 0:
print("Valid - Northbound")
else:
print("Valid - Southbound")
else:
print("Invalid Flight")

Copilot uses AI. Check for mistakes.

validate_flight_number("FL-JO234-JNB-CPT-2023")

Comment on lines +88 to 89
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 function call should be removed. It appears to be debugging/test code left in the production file and will execute every time the module is imported.

Suggested change
validate_flight_number("FL-JO234-JNB-CPT-2023")

Copilot uses AI. Check for mistakes.
# ==========================================
# SECTION B: ALGORITHMIC LOGIC (MATH)
Expand All @@ -71,10 +105,15 @@ def is_leap_year(year: int):

Return True or False (Boolean).
"""
# TODO: Write your code here
pass


#TODO: Write your code here
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 space after # in the comment. Should be # TODO: for consistency with code style.

Suggested change
#TODO: Write your code here
# TODO: Write your code here

Copilot uses AI. Check for mistakes.
if year % 4 != 0:
return False
elif year % 100 != 0 :
return False
else:
if year % 400 != 0:
return False

Comment on lines +110 to +116
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 leap year logic is incorrect. The current implementation returns False for years divisible by 4 but not by 100 (line 111-112), which is wrong. According to the rules: if divisible by 4 AND NOT by 100, it should return True. If divisible by 100, check if divisible by 400. The logic should be: if year % 4 != 0: return False, elif year % 100 != 0: return True, else: return year % 400 == 0.

Suggested change
return False
elif year % 100 != 0 :
return False
else:
if year % 400 != 0:
return False
return False
elif year % 100 != 0:
return True
else:
return year % 400 == 0

Copilot uses AI. Check for mistakes.
# ==========================================
# SECTION C: COMPLEX LOGIC & TDD
# ==========================================
Expand Down Expand Up @@ -104,5 +143,7 @@ def reactor_status(temp: int, radiation: int):
5. NORMAL:
- For all other cases: return "Normal Operation"
"""
# TODO: Write your code here
pass
#TODO: Write your code here
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 space after # in the comment. Should be # TODO: for consistency with code style.

Suggested change
#TODO: Write your code here
# TODO: Write your code here

Copilot uses AI. Check for mistakes.
if temp < 0 or radiation < 0:
return "Sensor Error"

Comment on lines +148 to +149
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 reactor_status function is incomplete. According to the docstring (lines 143-145), it should handle multiple cases: CRITICAL (temp > 2000 OR radiation > 500), WARNING (temp between 1000-2000 AND radiation > 100), MAINTENANCE (temp < 500), and NORMAL (all other cases). Currently, only the "Sensor Error" case is implemented.

Suggested change
return "Sensor Error"
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.
10 changes: 10 additions & 0 deletions test_reactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unittest
from system_check import reactor_status

Comment on lines +2 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.

Import of 'reactor_status' is not used.

Suggested change
from system_check import reactor_status

Copilot uses AI. Check for mistakes.
class TestReactor(unittest.TestCase):

def test_reactor(self):
self.assertEqual(
)
if '__name__' == '__main__':
unittest.main
Comment on lines +8 to +10
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 assertEqual call is missing both arguments. It should compare an actual value with an expected value, e.g., self.assertEqual(reactor_status(100, 50), "Maintenance Mode").

Suggested change
)
if '__name__' == '__main__':
unittest.main
reactor_status(100, 50), "Maintenance Mode"
)
if __name__ == '__main__':
unittest.main()

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +10
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 condition check is incorrect. '__name__' is a string literal, not a variable. It should be if __name__ == '__main__': (without quotes around __name__).

Suggested change
if '__name__' == '__main__':
unittest.main
if __name__ == '__main__':
unittest.main()

Copilot uses AI. Check for mistakes.
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 parentheses for the function call. It should be unittest.main() to execute the function.

Suggested change
unittest.main
unittest.main()

Copilot uses AI. Check for mistakes.