-
-
Save hexbinoct/ea2ababaf1a7b3e71329a04ba624d5c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
herdsize = input("Enter herd size:") | |
records = {} #initialize record where cow names and data will be stored | |
minimumdata = {} #record data which is below minimum yield | |
totaldays = 2 | |
minimumyield = 5 #litres | |
def Processing(): | |
for i in range(1,totaldays+1): | |
print("Day " +str(i) +":") | |
print("-----------") | |
#return | |
for j in range(0,herdsize): | |
cowname = raw_input("enter cow identity:") | |
if not cowname in records: | |
records[cowname]=[] #initialize array for this cowname if first time | |
#data1[i]=0 | |
milkqty = raw_input("how much milked:") | |
records[cowname].append(milkqty) | |
totalyield = 0.0 #all days | |
topcowname = "" | |
topcowyield = 0.0 | |
print() | |
print("--------------------") | |
print(" RESULTS ") | |
print("--------------------") | |
for k in records: | |
cowname = k | |
cowdata = records[k] #array of values (milk recorded) | |
cowaverage = 0 | |
cowyieldtmp = 0 | |
for value in cowdata: | |
milkquantity = float(value) | |
totalyield = totalyield+milkquantity | |
cowaverage = cowaverage+milkquantity | |
cowyieldtmp = cowyieldtmp + milkquantity | |
if milkquantity<minimumyield: | |
if not cowname in minimumdata: | |
minimumdata[cowname] = 0 #initialize | |
minimumdata[cowname] = minimumdata[cowname]+1 | |
if cowyieldtmp>topcowyield: | |
topcowname = cowname | |
topcowyield = cowyieldtmp | |
print("average for "+cowname + ":" + str(cowaverage/totaldays)) | |
print("total yield for all cows: "+str(round(totalyield,0))) | |
print("most productive cow: "+ topcowname+ ", weekly yield: " + str(topcowyield)) | |
for cowname in minimumdata: | |
if minimumdata[cowname]>4: | |
print("unsatisfactory yield: "+cowname) | |
Processing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment