I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks!
class Animal:
def __init__(self, name, types, species, mass):
self.name=name
self.type=types
self.specie=species
self.mass=mass
def getName(self):
return self.name
def getType(self):
return self.type
def getSpecies(self):
return self.specie
def getMass(self):
return self.mass
class Mammal(Animal):
def __init__(self,name, types, species, mass, litterSize):
super().__init__(self, name, types, species, mass)
self.litterSize=litterSize
def getLitterSize(self):
return self.litterSize
class Reptiles(Animal):
def __init__(self, name, types, species, mass, VenemOrNot):
super().__init__(self, name, types, species, mass)
self.VenomOrNot=VenomOrNot
def getVenomOrNot(self):
return self.VenomOrNot
class Birds(Animal):
def __init__(self, name, types, species, mass, Wingspan,
TalksOrMute, phrase):
super().__init__(self, name, types, species, mass)
self.Wingspan=Wingspan
self.TalksOrMute=TalksOrMute
self.phrase=phrase
def getWingspan(self):
return self.Wingspan
def TalksOrMute(self):
return self.TalksOrMute
def getPhrase(self):
return self.phrase
if __name__=='__main__':
file_read=open('Animals.txt', 'r')
animalsList=[]
for line in file_read:
details=line.split()
if details[1]=="Mammal":
m=Mammal(details[0], details[1], details[2], details[3],
details[4])
animalsList.appened(m)
elif details[1]=="Reptile":
r=Reptile(details[0], details[1], details[2], details[3],
details[4])
animalsList.append(r)
elif details[1]=="Bird":
phrase=""
if details[5]=="Talks":
phrase=file_read.readline().rstrip('\n')
b=Birds(details[0], details[1], details[2], details[3], details[4],
details[5], phrase)
animalsList.append(b)
while True:
choice=input('Query animal species[s], mass[m], litter[l],
venom[v], wingspan[w], talk[t] or exit session[e]?')
if choice=='s':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName():
print(name, 'species is', animal.getSpecies())
break
else:
print(name, 'not present')
elif choice=='m':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName():
print(name,'mass is', animal.getMass())
break
else:
print(name, 'not present')
elif choice=='l':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=="Mammal":
print(name, 'litter Size is', animal.getLitterSize())
break
else:
print(name, 'not present')
elif choice=='v':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=='Reptile':
print(name, 'is', animal.getVenomOrNot())
break
else:
print(name, 'not present')
elif choice=='w':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=='Birds':
if animal.getTalksOrMute()=="Mute":
print(name,'Is Mute')
else:
print(name, 'talks')
print(name, 'says', animal.getPhrase())
break
else:
print(name, 'not present')
elif choice=='e':
print('Goodbye!')
break
else:
print('Invalid choice entered')
Below is the information which exists in my. txt file:
Bob Mammal Bear 300
2
Lucy Reptile Lizard 2
Nonvenomous
Carl Reptile Cottonmouth 3
Venomous
Oliver Bird Ostrich 75
60 Mute
Polly Bird Parrot 1
2 Talks
I want a cracker
Doug Mammal Dog 20
4
If you have any doubts, please give me comment....


![if_name_=-main-: 43 file_read-open Animals.txt, r animal s List=[] 45 for line in file_read: 46 details-line.split) 47](http://img.homeworklib.com/images/83b52556-3c99-49eb-a770-b9f2c7f1c57e.png?x-oss-process=image/resize,w_560)
![while True: 60 choice-input( Query animal species[s], mass[m], litterll], venom[v], 61 wingspan[w], talk[t] or exit session[](http://img.homeworklib.com/images/e6eeee0a-5978-49a5-9848-ae1c2ec5df1d.png?x-oss-process=image/resize,w_560)


Animals.txt
Bob Mammal Bear 300 2
Lucy Reptile Lizard 2 Nonvenomous
Carl Reptile Cottonmouth 3 Venomous
Oliver Bird Ostrich 75 60 Mute
Polly Bird Parrot 1 2 Talks
I want a cracker
Doug Mammal Dog 20 4
Code:
class Animal:
def __init__(self, name, types, species, mass):
self.name=name
self.type=types
self.specie=species
self.mass=mass
def getName(self):
return self.name
def getType(self):
return self.type
def getSpecies(self):
return self.specie
def getMass(self):
return self.mass
class Mammal(Animal):
def __init__(self,name, types, species, mass, litterSize):
super().__init__(name, types, species, mass)
self.litterSize=litterSize
def getLitterSize(self):
return self.litterSize
class Reptile(Animal):
def __init__(self, name, types, species, mass, VenomOrNot):
super().__init__(name, types, species, mass)
self.VenomOrNot=VenomOrNot
def getVenomOrNot(self):
return self.VenomOrNot
class Birds(Animal):
def __init__(self, name, types, species, mass, Wingspan, TalksOrMute, phrase):
super().__init__(name, types, species, mass)
self.Wingspan=Wingspan
self.TalksOrMute=TalksOrMute
self.phrase=phrase
def getWingspan(self):
return self.Wingspan
def TalksOrMute(self):
return self.TalksOrMute
def getPhrase(self):
return self.phrase
if __name__=='__main__':
file_read=open('Animals.txt', 'r')
animalsList=[]
for line in file_read:
details=line.split()
if details[1]=="Mammal":
m=Mammal(details[0], details[1], details[2], details[3], details[4])
animalsList.append(m)
elif details[1]=="Reptile":
r=Reptile(details[0], details[1], details[2], details[3], details[4])
animalsList.append(r)
elif details[1]=="Bird":
phrase=""
if details[5]=="Talks":
phrase=file_read.readline().rstrip('\n')
b=Birds(details[0], details[1], details[2], details[3], details[4], details[5], phrase)
animalsList.append(b)
while True:
choice=input('Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]?')
if choice=='s':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName():
print(name, 'species is', animal.getSpecies())
break
else:
print(name, 'not present')
elif choice=='m':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName():
print(name,'mass is', animal.getMass())
break
else:
print(name, 'not present')
elif choice=='l':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=="Mammal":
print(name, 'litter Size is', animal.getLitterSize())
break
else:
print(name, 'not present')
elif choice=='v':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=='Reptile':
print(name, 'is', animal.getVenomOrNot())
break
else:
print(name, 'not present')
elif choice=='w':
name=input('Animal Name?')
for animal in animalsList:
if name==animal.getName() and animal.getType=='Birds':
if animal.getTalksOrMute()=="Mute":
print(name,'Is Mute')
else:
print(name, 'talks')
print(name, 'says', animal.getPhrase())
break
else:
print(name, 'not present')
elif choice=='e':
print('Goodbye!')
break
else:
print('Invalid choice entered')
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
I am having trouble with my Python code in this dictionary and
pickle program. Here is my code but it is not running as i am
receiving synthax error on the second line.
class Student:
def__init__(self,id,name,midterm,final):
self.id=id
self.name=name
self.midterm=midterm
self.final=final
def calculate_grade(self):
self.avg=(self.midterm+self.final)/2
if self.avg>=60 and self.avg<=80:
self.g='A'
elif self.avg>80 and self.avg<=100:
self.g='A+'
elif self.avg<60 and self.avg>=40:
self.g='B'
else:
self.g='C'
def getdata(self):
return self.id,self.name.self.midterm,self.final,self.g
CIT101 = {}
CIT101["123"] = Student("123", "smith, john", 78, 86)
CIT101["124"] = Student("124", "tom, alter", 50,...
PYTHON PROGRAMMING: I have this program right now where it allows users to choose from a category(pulling from the file). Then it will print the University or people from that text file. What I want to do next on my code is for users to search for a specific string from that file and it will display both the University and People that have that matching string. It can be the whole word or part of the string from that...
i have problem where the address is not save to my file after i input a new address and exit it #include<string> #include<iostream> #include<fstream> #include<sstream> using namespace std; typedef struct date { int day; int month; int year; }Date; typedef struct add { string building; string street; string city; string state; string zip; }Address; typedef struct entry { string firstName; string lastName; Address address; string phNo; Date...