Question

Using python write a program. A chemist is performing four experiments and each experiment has five...

Using python write a program.

A chemist is performing four experiments and each experiment has five results. The results for each experiment are given in the following table. An experiment is considered successful if the average of the five test results for a given experiment is between 25 and 32. Using a nested loop, write a script that: - Compute and display the test results average for each experiment - Indicate is the experiment was successful or not

1st experiment results 49.1 15.8 16.9 25.2 33.4

2nd experiment results 34.8 45.2 27.9 36.8 23.4

3rd experiment results 26.4 16.8 10.2 15.8 18.9

4th experiment results 26.9 19.5 42.9 41.5 27.4

Hint : Use lists to store each experiment results and a single list to store the entire table

Homework Answers

Answer #1

experiment_results = [[49.1, 15.8, 16.9, 25.2, 33.4], [34.8, 45.2, 27.9, 36.8, 23.4],

[26.4, 16.8, 10.2, 15.8, 18.9], [26.9, 19.5, 42.9, 42.5, 27.4]]

experiment_no = 1

isSuccessfull = True

for experiment in experiment_results:

    s = 0

    for result in experiment:

        s += result

    avg = s/len(experiment)

    print(experiment_no, end=':\t')

    for result in experiment:

        print(result, end='\t')

    print("%.2f"%avg)

    if avg<25 or avg>32:

        isSuccessfull = False

    experiment_no+=1

if isSuccessfull:

    print("Experiment was successful")

else:

    print("Experiment was not successful")

Let me know if you have any clarifications... Thank you...

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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT