Question

You have the following list of lists: hr = [ [ 72, 75, 71, 73], #...

You have the following list of lists: hr = [ [ 72, 75, 71, 73], # resting [ 91, 90, 94, 93], # walking slowly [ 130, 135, 139, 142], # running on treadmill [ 120, 118, 110, 105, 100, 98] # after a minute recovery ] Each element is the heart rate of a patient. Each sub-list contains heart rates of patients after resting, walking, running, a minute after recovery. Not all sub-lists are of the same length. Write a Python program hr.py where you iterate through the list of lists hr and calculate the average of each sub-list. Append the average of each sub-list to a new list as you iterate through hr. Print this list of average heart rates at the end.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#list of lists representing the heart rates of a person at differenet situations

#list1 indicates resting time heart rate

#list2 indicates walking slowly time heart rate

#list3 indicates running on treadmill time heart rate

#list4 indicates after a minute recovery time heart rate

hr=[[72,75,71,73],[91,90,94,93],[130,135,139,142],[120,118,110,105,98,100]]

#hr1 is new list to store the averages of abpve sublists

hr1=[]

i=0

#iterating over the sub lists

for i in hr:

    count=0

    sum1=0

    for j in i:

        #calculating the sum of heart rates of sub lists

        sum1=sum1+j

        #counting the number of heart rates in a sub list

        count=count+1

    #finding the average of the sub list and applying the round to get the nearest integer

    average=round(sum1/count)

    #appending the sublists average to a list

    hr1.append(average)

#printing the new list
print("list of average values of sublists")
print(hr1)
#note : i have applied the round() to average values to look the list accurate.
#If you don't need just remove the round()

OUTPUT:

input list of average values of sublists [73, 92, 136, 108] ... Program finished with exit code o Press ENTER to exit console

#in each element in hr1 list indicates average of that sub list values

Add a comment
Know the answer?
Add Answer to:
You have the following list of lists: hr = [ [ 72, 75, 71, 73], #...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Recursion and Doubly Linked Lists Problem #1: Assume you have a doubly linked list of single...

    Recursion and Doubly Linked Lists Problem #1: Assume you have a doubly linked list of single characters. Plan the algorithm to insert character 'a' immediately before each character 'b' that is encountered. 3. What is the simple case: (what case does not require a loop?) How do we get to the next a smaller sub-problem? What information is needed for the function call: 4. If we insert ‘a, PRIOR to the recursive call, what do we need to be careful...

  • Medical Report Assignment #1 The assignment: you are a general medical doctor, and you must prepare a History & Phys...

    Medical Report Assignment #1 The assignment: you are a general medical doctor, and you must prepare a History & Physical and write some prescriptions based on the information below. The information is not in the correct order for the report, so you will need to put it in the correct order. You can use the History & Physical on page 42 in the textbook as a general guide, as well as the lectures, but your History & Physical must follow...

  • Pre-Laboratory Exercise: Plastics Identification I. List four properties that you will use in lab...

    can someone help me find this information? Pre-Laboratory Exercise: Plastics Identification I. List four properties that you will use in lab to determine the identity of the polymer samples 2. Describe the density test. What observation will help you determine the density of each polymer? What precautions should be taken in placing the sample in the solutions? 3. Write the name and abbreviation for the six recyclable polymers 2 huetn deisity polyetayene.HDpz poulene: PP 4. Given the list of wavenumber...

  • Hello, could you help me with it . 55. A flowmeter has a completely closed needle...

    Hello, could you help me with it . 55. A flowmeter has a completely closed needle valve, and the ball jumps then retums to zero when the flowmeter is plugged into a gas source. Which of the following is correct? I aBourdon gauge is being used II it is a Thorpe tube flowmeter III. it is a back-pressure compensated flowmeter IV. the needle valve is malfunctioning A B. C. D. I & IV II & III I,II & III II,...

  • 1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below,...

    1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below, how would you describe THE COMPANY’s approach to recruitment, before and after the implementation of the Brand Ambassador Program? How did the use of social media lead to the revision of the whole approach regarding recruitment? How ‘THE COMPANY’ Developed a Brand Ambassador Program At ‘THE COMPANY’ we usually categorize Employment Brand at ‘THE COMPANY’ into four big ‘buckets’: candidate experience, brand ambassador programs,...

  • Home Insert Draw Page Layout Formulas Data Review View Help Tell me what you want to...

    Home Insert Draw Page Layout Formulas Data Review View Help Tell me what you want to do = = ). General Calibri B I 11 . Font - A A . .A. Wrap Text Merge & Center. U $ . % * 3 Alignment Number Clipboard R14 4. A . B C D G H nter the last 4 digits of your student ID number 4 Name/s: 7 Save this file in EXCEL FORMAT as: P2 Lastname 8 Round all...

  • 50. Client-centeredness and humility might look like saying, "Tell me about what's most important to you...

    50. Client-centeredness and humility might look like saying, "Tell me about what's most important to you here." True False 51. Appropriate regression means introducing new tasks weekly. True False 52. Rewarding behaviors, not outcomes means focusing on measurements first. True False 53. A demonstration of your client's mental skills include: Going to the farmer's market, Following the "inner compass" Learning about protein All of the above are correct 54. During step 1 of the coaching process, aim to identify bright...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

  • As you know from Project 4, McCormick & Company is considering building a new factory in...

    As you know from Project 4, McCormick & Company is considering building a new factory in Largo, Maryland. McCormick & Company decided to offer $4,424,000 to obtain the land for this project. The new factory will require an initial investment of $350 million to build the new plant and purchase equipment. You have been asked to continue your work from project 4 with a full analysis of the proposed factory, including the start-up costs, the projected net cash flows from...

  • 69. THE ENDOSPORE itself is might to stain_?_ color in an ACID FAST stain. (a) HOT...

    69. THE ENDOSPORE itself is might to stain_?_ color in an ACID FAST stain. (a) HOT pink (c) purple (d) green (e) baby-blue 70. All STAINS begin with a properly prepared _?_ . (a) dye (b) slide (c) smear (d) dog (e) cat 71. Which of the following is an ENDOTOXIN found in some microbes? This is results in fever, blood vessel dilation and possibly SHOCK when it is released into the human blood stream? (a) the plasma membrane (b)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT