-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4-classification.py
60 lines (49 loc) · 1.46 KB
/
4-classification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
animals = [
['horse', 1,0,0,0,1,1,1,0,1,0,0],
['cow', 1,0,0,0,1,1,1,0,1,1,0],
['sheep', 1,0,0,0,1,0,1,0,1,1,0],
['pig', 1,0,0,0,1,0,1,1,1,1,0],
['dog', 1,0,0,0,1,0,1,1,1,0,0],
['zebra', 1,0,0,0,1,1,0,0,1,0,1],
['lion', 1,0,0,0,1,1,0,1,1,0,0],
['tiger', 1,0,0,0,1,1,0,1,1,0,1],
['whale', 1,1,0,0,0,1,0,0,1,0,0],
['dolphin', 1,1,0,0,0,0,0,1,1,0,0],
['seal', 1,1,0,0,1,0,0,1,1,0,0],
['penguin', 0,1,1,0,1,0,0,1,1,0,0],
['ostrich', 0,0,1,0,1,1,0,0,1,0,0],
['sparrow', 0,0,1,0,1,0,0,0,1,0,0],
['spider', 0,0,0,0,1,0,0,1,1,0,0],
['ant', 0,0,0,1,1,0,0,0,1,0,0],
['bee', 0,0,0,1,1,0,0,0,1,0,1],
['wasp', 0,0,0,1,1,0,0,1,1,0,1],
['termite', 0,0,0,1,1,0,0,1,1,0,0],
['octopus', 0,1,0,0,1,0,0,1,1,0,0],
['squid', 0,1,0,0,0,0,0,1,1,0,0]
]
questions = [
'Is it a mammal?',
'Does it live in the water?',
'Is it a bird?',
'Is it an insect?',
'Can it survive on land?',
'Is it a large animal (bigger than a human)?',
'Is it a domesticated animal?',
'Is it a carnivore (eats meat)?',
'Is it a herbivore (eats plants)?',
'Is it farmed for food?',
'Does it have stripes?'
]
answers = []
for question in questions:
answer = input(question+': ')
if answer == '': answer = ' '
if answer[0].lower() == 'y':
answers.append(1)
else:
answers.append(0)
guess = [animal for animal in animals if animal[1:len(animal)] == answers]
if guess:
print('Your animal is a '+guess[0][0])
else:
print('I dont know what animal you are talking about')