Intro to Computer Science

PA02

Working with Selection Statements


Code due by Friday, Feb. 3rd at 11:00 AM


Introduction

This week we have been working with selection statements.  Let's see if you understand this idea.

Just like last week, in this assignment I would like you to :

  1. Look at the two customer requests below (step #1 in the software development process). 
  2. After you have studied the problems and prepared your problem solving solution you should write the code that solves each of the problems.  Please make sure that you write the code in two separate files saved with the names given below.
  3. Once you think you have the code working, TEST it thoroughly. 

Notes and requirements:


Customer Request #1 (weight.py)

You are contacted by Dr. Zoltan Pepper who is analyzing the overall fitness of olympic athletes.  To help understand how they compare he has decided to use the concept of Body Mass Index (BMI). 

BMI is a number calculated from a person's weight and height.  It does not measure body fat directly, but research has shown that it correlates well with body fat calculations from more dependable measures such as underwater weighing.  The formula for BMI is:

        BMI  = weight / height2

where weight is in kilograms and height is in meters.

For example, Peter Kirkbride (a weightlifter from the UK) is 74.5 inches tall and weighs 207 lbs.  This means his BMI is 26.2213925..

[Note, 1 inch is 2.54 centimeters.  1 pound is 0.453592 kg]

Dr. Pepper also points out the following table from the CDC

BMI Weight Status
Below 18.5 Underweight
Below 25 (but 18.5 or higher) Normal
Below 30 (but 25 or higher Overweight
30.0 and above Obese

 

Dr. Pepper asks you to write a program that:


Customer Request #2 (calculator.py)

Esther Mate's favorite subject at school has always been mathematics. She asks you to write a script (called calculator.py) that:

For example

Hint: The operator will be coming in as a string, and you cannot use it directly in computations. You will need to determine if the string operator is one of the valid operators using conditional statements.

Be sure your program's output matches the above screenshot (the errors triggered and the order of questions asked) to receive the most points.


Final Submission

To upload your homework for grading, log on to eLearning, select this class, and navigate to the "Assignment Submissions" area. Click on the "Programming Assignment 2" folder and upload both python files in their designated locations.