Python programming;
Pass the list pathogens to the function as an
argument.
Return 'Done!' instead of printing it: instead have the
caller print whatever is returned.
pathogens = ['MRSA', 'E.coli', 'C.difficile']
for bacteria in pathogens:
doubling_time = float(input("What is the doubling time in hours of
" + bacteria+"? "))
population = 2** (int(24/doubling_time))
print ("In 24 hours, the population of "+ bacteria+" will go from 1
to " + str(population) )
print ('Done!')
Below is the solution:
def pathogensFunction(pathogens): #function definition of passed the paremeter of pathogens list for bacteria in pathogens: doubling_time = float(input("What is the doubling time in hours of " + bacteria + "? ")) population = 2 ** (int(24 / doubling_time)) print("In 24 hours, the population of " + bacteria + " will go from 1 to " + str(population)) #print('Done!') return "Done" #return Done #return(output_list) pathogens = ['MRSA', 'E.coli', 'C.difficile'] #pathogens list print(pathogensFunction(pathogens)) #function that pass the pathogens list and print
sample output:
Get Answers For Free
Most questions answered within 1 hours.