Expert system. Imperative languages

12.5.1.2 create a simple expert system

Expert system. Imperative languages

Example of an expert system

Implementation in Python:

flag = True
while flag:
    answer1 = input("Power supply? (y/n) ")
    if answer1.lower() == "y":
        answer2 = input("No power? (y/n) ")
        if answer2.lower() == "y":
            answer3 = input("Source power is off? (y/n) ")
            if answer3.lower() == "y":
                print("Switch on source power")
            elif answer3.lower() == "n":
                print("Check power cable")
            else:
                print("Error")
        elif answer2.lower() == "n":
            answer4 = input("PC power on button is off? (y/n) ")
            if answer4.lower() == "y":
                print("Switch on computer")
            elif answer4.lower() == "n":
                print("Check computer power cable")
            else:
                print("Error")
        else:
            print("Error")
    elif answer1.lower() == "n":
        answer5 = input("No LED light? (y/n) ")
        if answer5.lower() == "y":
            answer6 = input("Internal power cable is disconnected? (y/n) ")
            if answer6.lower() == "y":
                print("Internal power cable is disconnected")
            elif answer6.lower() == "n":
                print("Check connect")
            else:
                print("Error")
        elif answer5.lower() == "n":
            answer7 = input("No sound from power supply? (y/n) ")
            if answer7.lower() == "y":
                print("Change power supply")
            elif answer7.lower() == "n":
                print("Clean power supply fan")
            else:
                print("Error")
        else:
            print("Error")
    else:
        print("Error")
    ans = input("Do you have any questions? (y/n) ")
    if ans.lower() == "n":
        flag = False
print("The program is ended!")


Questions:


Exercises:


Exam questions:

 

Категория: Algorithms | Добавил: bzfar77 (15.09.2021)
Просмотров: 143 | Теги: Python, Expert systems, Artificial Intelligence | Рейтинг: 5.0/1
Всего комментариев: 0
avatar