0% found this document useful (0 votes)
14 views

Computational Thinking1

Uploaded by

karnanikhwahish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Computational Thinking1

Uploaded by

karnanikhwahish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

COMPUTATIONAL

THINKING
Presented By : Khwahish Karnani , Navya
Jain & Krishhiv Jallan
4
DECISION TREE
Automating the decision tree
An expert system is made of logical
tests. A good way to set out the tests is If something is automated it can work on
to draw a decision tree that shows all its own without a human user.To automate a
decision tree, you turn it into a program.
the decisions. By following the
Each branch of the tree represents an if...
branches of the tree, you can get to the
else structure.
right decision.The decisions are shown
in square boxes. After each decision
The if structures are nested inside
you must branch either left or right.
each other. You will learn more
The branches are labelled. Each branch
stands for a different choice. You can
about this in the next lesson.
use the decision tree to find an answer
to a question.
5
AUTOMATE A DECISION TREE
Start the program
1 Load the empty signal processing program which is provided. This gives you the list called signals. It contains all
the signals, good and bad. Now you will automate the decision tree. It will sort the signals into two lists - the
good signals and the bad signals.
2 Make good and bad lists
At the start of the program, create two empty lists. They are called good_signals and bad_signals. You will
append items to these lists. Remember that append means 'add to the end of a list.
good_signals= []
bad signals = []
No. of characters 5

Example
2 or fewer 3 or more

bad signal
Does it contain #?

no
yes

bad signal Does it contain


spaces?

yes no
good signal bad signal
6
AUTOMATE A DECISION TREE
Add the first branch
Now you will put if…..else structures inside the loop Remember that one structure inside another is called a
nested structure. A nested structure has double indentation. This decision tree will use lots of nested indentation

The first decision is based on the length of the signal


1. if the signal has fewer than three characters it is appended to the bad strings.
2. Else the program prints out “more tests required”. You will add more tests later.

The if structure is nested inside the loop. That means the test will be carried out every time the loop repeats.
7
CONTINUE THE DECISION TREE
Continue the decision tree
Delete the command to print "more tests required", Now you will add the extra
tests.
The next branch of the decision tree checks if the character # is in the signal
If “#” in item:
bad_signals.append(item)
FINAL BRANCH OF THE 8

DECISION TREE
Finally, you will add the third branch of the ☆ decision tree.

if "#" in item:
bad_signals.append(item)
else:

Now type the final test. This test checks if the signal includes a space.
if “ “ in item:
Good strings contain a space. Bad strings do not.
Here is the completed program. This program includes every test from the decision tree.
7
CONCLUSION:EXPERT SYSTEM & AI
Here is the completed program. This program includes every test from the decision tree.
good signals = []
bad signals = []

for item in signals:


if len (item) < 3;
bad signals.append(item)
else:
if "#" in item:
bad signals.append(item)
else:
if “ ”in item:
good signals.append(item)
else:
bad_signals.append(item)

print (bad signals)


print (good_signals)
THANK YOU
Presented By : Khwahish Karnani , Navya Jain &
Krishhiv Jallan

You might also like