Question

Python programming; Pass the list pathogens to the function as an argument.   Return 'Done!' instead of...

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!')

Homework Answers

Answer #1

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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT