diff --git a/__pycache__/system_check.cpython-310.pyc b/__pycache__/system_check.cpython-310.pyc new file mode 100644 index 0000000..f1d75cf Binary files /dev/null and b/__pycache__/system_check.cpython-310.pyc differ diff --git a/system_check.py b/system_check.py index 6c19688..027bcc4 100644 --- a/system_check.py +++ b/system_check.py @@ -1,3 +1,4 @@ +import re # ========================================== # SECTION A: DATA PARSING (FLIGHT TICKET SYSTEM) # ========================================== @@ -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 + return def check_baggage_allowance(ticket_string: str): """ @@ -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" def validate_flight_number(ticket_string: str): """ @@ -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) + # ========================================== @@ -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 @@ -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" + elif temp < 500: + return f"Maintenance Mode" + else: + return f"Normal Operation" diff --git a/test_reactor.py b/test_reactor.py new file mode 100644 index 0000000..0ea46c4 --- /dev/null +++ b/test_reactor.py @@ -0,0 +1,13 @@ +import unittest +from system_check import reactor_status + +class testReactor(unittest.TestCase): + 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() \ No newline at end of file