Question
given the class livestock write the following functions using python: raw data here is a sample data raw_livestock_data = [ # name, price_in, utilizations ['Dog',
given the class livestock
write the following functions using python:
raw data
here is a sample data
raw_livestock_data = [ # name, price_in, utilizations ['Dog', '200.0', 'Draught,Hunting,Herding,Searching,Guarding.'], ['Goat', '1000.0', 'Dairy,Meat,Wool,Leather.'], ['Python', '10000.3', ''], ['Cattle', '2000.75', 'Meat,Dairy,Leather,Draught.'], ['Donkey', '3400.01', 'Draught,Meat,Dairy.'], ['Pig', '900.5', 'Meat,Leather.'], ['Llama', '5000.66', 'Draught,Meat,Wool.'], ['Deer', '920.32', 'Meat,Leather.'], ['Sheep', '1300.12', 'Wool,Dairy,Leather,Meat.'], ['Rabbit', '100.0', 'Meat,Fur.'], ['Camel', '1800.9', 'Meat,Dairy,Mount.'], ['Reindeer', '4000.55', 'Meat,Leather,Dairy,Draught.'], ['Mule','4400.2', 'Draught.'], ] class Livestock: def __init__(self,name,price_in,utilizations): self.name,self.price_in,self.utilizations = name,float(price_in),utilizations def __lt__(self,other): if self.utilizations is None: return True elif other.utilizations is None: return False else: return self.utilizations.count(';') class Livestock: #initializing all the atributes def __init__(self, name,price_in,utilizations): self.name, self.price_in,self.utilizations = name,float(price_in), utilizations #making class sortable by implementing It method using in internal sort in python def_lt_(self,other): #if current instance has no utilization if self.utilizations is None: return True #if other instance has no utilization elif other.utilizations is None: return false #check which object has more utilization else: return self.utilizations.count(';')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started