hw05.pdf - hw05_master 1 Homework 5 Applying Functions and Iteration Please complete this notebook by filling in the cells provided Before you begin

# hw05.pdf - hw05_master 1 Homework 5 Applying Functions and...

• 10
• 89% (9) 8 out of 9 people found this document helpful

This preview shows page 1 - 4 out of 10 pages.

[2]: exercise = Table . read_table( 'exercise.csv' ) exercise [2]: Day (in January) | yoga | walking | sprinting | volleyball 1 | 50 | 0 | 0 | 0 2 | 0 | 65 | 0 | 65 3 | 50 | 70 | 0 | 0 4 | 0 | 0 | 0 | 75 5 | 0 | 0 | 0 | 0 6 | 0 | 0 | 0 | 0 7 | 0 | 0 | 0 | 0 8 | 0 | 55 | 0 | 0 9 | 0 | 0 | 0 | 0 10 | 0 | 30 | 0 | 0 … (21 rows omitted) Different forms of exercise burn calories at different rates; for example, sprinting is more vigorous than walking. The table calories_per_minute contains estimates of the calories per minute burned by each activity. [3]: calories_per_minute = Table . read_table( 'calories_per_minute.csv' ) calories_per_minute [3]: Exercise | Calories per minute yoga | 6 walking | 5 sprinting | 20 volleyball | 4 Let’s start by finding the total number of minutes you spent exercising each day. Question 1. Write a function called compute_exercise_time . It should take one argument, a row from the exercise table that contains the day and amounts of time (in minutes) spent on yoga, walking, sprinting, and volleyball. It should return the total time spent exercising. Hint You can tbl.row(n) to get the n th row of a table. row.item("column_name") will allow you to select the element that corresponds to column_name in a particular row. BEGIN QUESTION name: q1_1 manual: false [4]: """ # BEGIN PROMPT def compute_exercise_time(exercise_row): ... """ ; # END PROMPT # BEGIN SOLUTION NO PROMPT def compute_exercise_time (exercise_row): yoga_time = exercise_row . item( "yoga" ) 2
walking_time = exercise_row . item( "walking" ) sprinting_time = exercise_row . item( "sprinting" ) volleyball_time = exercise_row . item( "volleyball" ) return yoga_time + walking_time + sprinting_time + volleyball_time # END SOLUTION

#### You've reached the end of your free preview.

Want to read all 10 pages?

• Fall '17
• Playing card, Sprinting

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern