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:
Ex. 1
Create an expert system in terms of main memory “RAM”, “ROM”, “Cache memory”, “Virtual memory”. Build structure and write programming code to implement an expert system in your copybook.
Ex. 2
Create an expert system for terms of data types “Int”, “Float”, “1D array”, “2D array”. Build structure and write programming code to implement an expert system in your copybook.
Ex. 3
Create an expert system for terms of databases “non-normalized”, “1NF”, “2NF”, and “3NF”. Build structure and write programming code to implement an expert system in your copybook.
Exam questions:
|