def calculate_event_diff(event_id1, event_id2):
if event_id1 < event_id2:
return f"Event {event_id1} occurred before Event {event_id2}"
elif event_id1 > event_id2:
return f"Event {event_id1} occurred after Event {event_id2}"
else:
return f"Event {event_id1} and Event {event_id2} are the same"
# Input event IDs from the user
try:
event_id1 = int(input("Enter the first event ID: "))
event_id2 = int(input("Enter the second event ID: "))
# Call the comparison function and print the result
result = calculate_event_diff(event_id1, event_id2)
print(result)
except ValueError:
print("Invalid input. Please enter valid event IDs as integers.")
#this script defines a function (calculate_event_diff) which will take 2 event IDs as inputs comparing them as integers. Within the function, compare the event IDs returning a message that'll show if an event occurred before, after or same time as the other one. Script will prompt user to input two event IDs as integer. Will then call the (calculate_event_diff) function and print the result.