Skip to content

aisha#9

Open
proaisha127 wants to merge 1 commit into
micanipho:mainfrom
proaisha127:main
Open

aisha#9
proaisha127 wants to merge 1 commit into
micanipho:mainfrom
proaisha127:main

Conversation

@proaisha127
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR appears to be a homework/exercise submission that implements several functions for a flight ticket system and date validation. The changes include implementations for parsing flight ticket data, validating flight numbers, and checking leap years. However, the implementations contain multiple critical bugs and logic errors.

Key Changes

  • Implementation of get_departure_airport, check_baggage_allowance, and validate_flight_number functions for flight ticket parsing
  • Implementation of is_leap_year function for date validation
  • Commenting out of the reactor_status function and section headers
Comments suppressed due to low confidence (5)

system_check.py:72

  • This statement is unreachable.
    if ticket_string[7]!=2 or 4 or 6 or 8 or 0:

system_check.py:22

  • Print statement may execute during import.
print(get_departure_airport("FL-JO234-JNB-CPT-2023"))

system_check.py:51

  • Print statement may execute during import.
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))

system_check.py:76

  • Print statement may execute during import.
print(validate_flight_number("FL-JOABC-JNB-CPT"))

system_check.py:112

  • Print statement may execute during import.
print(is_leap_year(2020))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread system_check.py
pass
# # TODO: Write your code here
# pass
return ticket_string[9] +ticket_string[10] +ticket_string[11]
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 string concatenation with + operator is inefficient and hard to read. Consider using string slicing instead: return ticket_string[9:12]. This is more concise and follows Python best practices for extracting substrings.

Suggested change
return ticket_string[9] +ticket_string[10] +ticket_string[11]
return ticket_string.split('-')[2]

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
# # TODO: Write your code here
# pass
return ticket_string[9] +ticket_string[10] +ticket_string[11]
print(get_departure_airport("FL-JO234-JNB-CPT-2023"))
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.

Debug print statement should be removed before committing code. This appears to be leftover from testing.

Suggested change
print(get_departure_airport("FL-JO234-JNB-CPT-2023"))

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +43 to +50
if ticket_string[0]+ticket_string[1]=='EC':
return "Economy - 20kg"
elif ticket_string[0]+ticket_string[1]=='BS':
return "Business - 40kg"
elif ticket_string[0]+ticket_string[1]=='FL':
return "First Class - 60kg"
else:
return "Standard - 0kg"
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.

String concatenation with + operator is inefficient and hard to read. Consider using string slicing: ticket_string[:2] or the split method as mentioned in the function requirements.

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +51 to 54
print(check_baggage_allowance("FL-JO234-JNB-CPT-2023"))



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.

Debug print statement should be removed before committing code. This appears to be leftover from testing.

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

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +67 to +75
# # TODO: Write your code here
# pass

if ticket_string[7]==2 or 4 or 6 or 8 or 0:
return "Valid - Northbound"
if ticket_string[7]!=2 or 4 or 6 or 8 or 0:
return "Valid - Southbound"
if not ticket_string.isdigit():
return "Invalid Flight"
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 condition has the same logical error as line 70. Additionally, this logic is flawed because it doesn't properly extract and validate the numeric portion of the flight number. The function should: 1) split the string to get the flight number segment, 2) extract only the numeric portion, 3) check if it's a valid number, and 4) check if it's even or odd.

Suggested change
# # TODO: Write your code here
# pass
if ticket_string[7]==2 or 4 or 6 or 8 or 0:
return "Valid - Northbound"
if ticket_string[7]!=2 or 4 or 6 or 8 or 0:
return "Valid - Southbound"
if not ticket_string.isdigit():
return "Invalid Flight"
import re
# Split the ticket string by hyphens
parts = ticket_string.split('-')
if len(parts) < 2:
return "Invalid Flight"
flight_segment = parts[1]
# Extract numeric portion from flight_segment
match = re.search(r'(\d+)', flight_segment)
if not match:
return "Invalid Flight"
number_str = match.group(1)
try:
number = int(number_str)
except ValueError:
return "Invalid Flight"
if number % 2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
pass
# # TODO: Write your code here
# pass
return ticket_string[9] +ticket_string[10] +ticket_string[11]
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 implementation uses hardcoded indices which violates the stated requirement: "You cannot use fixed indices (e.g., [10:13]) because the Flight Number (JO234) can vary in length." The correct approach is to find the departure airport by splitting on hyphens: return ticket_string.split('-')[2].

Suggested change
return ticket_string[9] +ticket_string[10] +ticket_string[11]
return ticket_string.split('-')[2]

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
return "Valid - Southbound"
if not ticket_string.isdigit():
return "Invalid Flight"
print(validate_flight_number("FL-JOABC-JNB-CPT"))
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.

Debug print statement should be removed before committing code. This appears to be leftover from testing.

Suggested change
print(validate_flight_number("FL-JOABC-JNB-CPT"))

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +96 to +110
year=12
a=4
b=100
c=400

if year%a==0:
if year%b==0:
if year%c==0:
return True
else:
return False
else:
return True
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.

These variable names (a, b, c) are not descriptive. Use meaningful names like divisor_four, divisor_hundred, and divisor_four_hundred, or better yet, use the numeric literals directly in the conditions for clarity.

Suggested change
year=12
a=4
b=100
c=400
if year%a==0:
if year%b==0:
if year%c==0:
return True
else:
return False
else:
return True
else:
return True
# Use the function argument 'year' directly
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
----------------------------------------
Extract the Flight Number (the part between 1st and 2nd hyphen, e.g., "JO234").

"FL-JO234-JNB-CPT-2023"
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.

Inconsistent formatting: Added extra indentation (8 spaces) before the example string. This line should be aligned with the other lines in the docstring using 4 spaces.

Suggested change
"FL-JO234-JNB-CPT-2023"
"FL-JO234-JNB-CPT-2023"

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
# - For all other cases: return "Normal Operation"
# """
# # 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.

This comment appears to contain commented-out code.

Suggested change
# pass

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants