Answered step by step
Verified Expert Solution
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.
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started