Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer both questions, the starter code for Exercise 1 is given and cannot be changed. Thank you In this exercise you are going to

Please answer both questions, the starter code for Exercise 1 is given and cannot be changed. Thank you

image text in transcribed

image text in transcribed

In this exercise you are going to write a program that calculates the average student height from a list of heights. The average height can be calculated by adding all the heights together and dividing by the total number of heights. For example, the student height is given in the list, student_heights = [180, 124,165,173,189,169,146] Then, 180+124+165+173+189+169+146=1146 and there are a total of 7 heights in student_heights . So, the calculated average height is: 11467=163.71428571428572 Average height rounded to 1-decimal place =163.7 Important: You can not use the sum() or len() functions in your answer. You should try to replicate their functionality using what you have learnt about for loops. Example input Example output 171.4 The starter code is given below. H \# Don't change the code below student_heights = input("Input a list of student heights (in cm ) separated by space: ").split() for n in range( , len(student_heights)): student_heights [n]= int (student_heights [n] ) Exercise 2 - BMI Calculator You wrote a program that calculates the Body Mass Index (BMI) from a user's weight and height for a single person. The BMI is a measure of someone's weight taking into account their height. e.g. If a tall person and a short person both weigh the same amount, the short person is usually more overweight. The BMI is calculated by dividing a person's weight (in kg ) by the square of their height (in m ): BMI=height2(m2)weight(kg) In this exercise, you change that program in such a way that the program will keep asking for the weight and height and display the BMI value with 1 decimal place until you enter a negative weight (then the program quits and display some message, e.g., Thank you for using BMI calculator ). No starter code is given for this exercise. However, you can use the solution of the previous

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago