This Python program models a simplified decision-making system that selects the best surgical method based on a predefined treatment plan.
The user provides their risk tolerance and treatment priority (e.g., recovery time or effectiveness), and the program recommends the most suitable surgical option.
# Define available surgical options
surgical_options = {
"minimally_invasive": {"risk": 2, "recovery": 5, "effectiveness": 7},
"open_surgery": {"risk": 5, "recovery": 10, "effectiveness": 9},
"robotic_assisted": {"risk": 3, "recovery": 6, "effectiveness": 8}
}
# Get patient preferences
risk_tolerance = int(input("Maximum acceptable risk (1 to 5): "))
priority = input("What is your priority? (recovery/effectiveness): ").strip()
# Select the best option
best_option = None
best_score = -1
for name, data in surgical_options.items():
if data["risk"] <= risk_tolerance:
score = data[priority]
if score > best_score:
best_score = score
best_option = name
# Display result
print("\n--- Result ---")
if best_option:
print(f"The best surgical option for you is: {best_option}")
else:
print("No suitable option found within your risk tolerance.")
Maximum acceptable risk (1 to 5): 3
What is your priority? (recovery/effectiveness): effectiveness
--- Result ---
The best surgical option for you is: robotic_assisted
- Surgical options are defined with attributes: risk, recovery time, and effectiveness
- The user inputs their maximum risk tolerance and treatment priority
- The program filters and scores each option based on the priority
- The highest-scoring option within the risk limit is selected and displayed