Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a simple program and submit it Write a program as a separate file, and upload it to the course website. Name the file bmi.py.

image text in transcribedimage text in transcribed

Write a simple program and submit it Write a program as a separate file, and upload it to the course website. Name the file "bmi.py". The program Body Mass Index (BMI) is a measure of body fat. It is equal to the body's weight, in kilograms, divided by the square of the body's height in meters. However, in the U.S. people typically use pounds and feet and inches. Your task is to write a program that gets a name, then gets height and weight in feet, inches, and pounds, converts these to kilograms and meters, calculates the BMI; and reports the BMI value. An example of using this program is shown below. Program structure Input Input a user's name (with a prompt), and save it in a variable. Then prompt for and input the user's height in feet and inches on a single line. Note that this is two numbers, which should be entered on the same line. A feature of Python, the .split() method, is used to splt the line into two parts, convert each part into a numeric value. Then prompt for the user's weight in pounds. This is a single number, convert it from the string input into the actual value. Process First multiply the weight in pounds by 0.453592, and save it in a new variable, to convert it to kilograms. Next convert the feet to a inches by multiplying by 12, and add that to the number of inches for example, 5 feet, 4 inches equals 64 inches. Save the result in a new variable. Multiply the height in inches by 0.0254 to get the height in meters, and save it in another variable. Thus 64 inches equals 1.6256 meters. Finally, calculate the BMI as (weight-in-kilograms / height-in-meters**2), and save this value in a variable. Output Print out the user's name, height, and weight, followed by the BMI value in a nicely formatted output message. See an example below. Program files must begin with a comment that specifies the programming language. Also add comments containing your name, the name of the assignment and a brief description of it (one line is sufficient), and the date you wrote it. For example: #!/usr/bin/env python # Alice Bytecoder # Assignment 1: Program to calculate BMI. # October 15, 1582 Example usage C:\115 C:\115> bmi.py Your name? Jane Doe Height (feet and inches)? 4 11 Weight (pounds)? 105 Jane Doe is 1.4986 meters tall, weighs 47.62611 kilograms. Jane Doe has a BMI of 21.206727417763943 C:\115> C:\115> bmi.py Your name? Stringy Bean III Height (feet and inches)? 6 7 Weight (pounds)? 120 Stringy Bean III is 2.0065999999999997 meters tall, weighs 54.42984 kilograms Stringy Bean III has a BMI of 13.5180933717099 C:\115>

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

5. Arranging for the training facility and room.

Answered: 1 week ago

Question

1. Discuss the five types of learner outcomes.

Answered: 1 week ago