Source Code:
def medical_diagnosis():
print("Welcome to the Medical Diagnosis Expert System")
print("Please answer the following questions with 'yes' or 'no'\n")
fever = input("Do you have a fever? ").lower()
cough = input("Do you have a cough? ").lower()
sore_throat = input("Do you have a sore throat? ").lower()
runny_nose = input("Do you have a runny nose? ").lower()
headache = input("Do you have a headache? ").lower()
body_ache = input("Do you have body aches? ").lower()
if fever == "yes" and cough == "yes" and body_ache == "yes":
print("\nDiagnosis: You may have the Flu.")
elif runny_nose == "yes" and sore_throat == "yes":
print("\nDiagnosis: You may have a Common Cold.")
elif fever == "yes" and headache == "yes" and sore_throat == "yes":
print("\nDiagnosis: You may have a Viral Infection.")
elif cough == "yes" and sore_throat == "yes" and fever == "no":
print("\nDiagnosis: You may have a Throat Infection.")
else:
print("\nDiagnosis: Symptoms are inconclusive. Please consult a doctor.")
medical_diagnosis()
Output: