Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SORRY about that its Python thank you so much Task 3: Write a comment line that says: Task 3 Print: Task 3 Write a comment:

image text in transcribed

SORRY about that its Python thank you so much

Task 3: Write a comment line that says: Task 3 Print: Task 3 Write a comment: Getting user input and computing BMI Declare a string variable called userName with an initial value of "Null" Declare a float variable called userWeight with an initial value of 0.0 Declare a float variable called userHeight with an initial value of 0.0 Ask the user their name and assign that value to the variable userName as string Ask the user their weight in pounds and assign that value to the variable userWeight as float Ask the user their height in inches and assign that value to the variable userHeight as float Declare afloat variable called userBMI with an initial value of 0.0 Compute the userBMI using the formula BMI . (Weight in Pounds / Height in inches squared) x 703 Display the userBMI value as: Dear, followed by cusername>, your BMI is, followed by the calculated BMI value Task 4: Write a comment line that says: Task 4 Print: Task 4 Write a comment: Assessing the BMI value using if elif satements Write an if and elif statement structure that looks at the BMI value and if its value is greater than or equal to 30, display the message: Dear cusername>, your BMI suggests you are obese Else, if the value is greater than or equal to 25, display the message: Dear , your BM suggests you are overweight, but not quite obese. Else, if the value is greater than or equal to 18.5, display the message: Dear , your BMI suggests your weight is in the normal range for your height. Else, display the messa ge: Dear cusername>, your BMI suggests your weight is below normal for your height. Task 5: Write a comment line that says: Task 5 Print: Task 5 Write a comment: Writing and calling a function called BMI Write a function called BMI with two parameters (or arguments) called height and weight and returns the BMI value Outside the function, just after the function, print: Dear username>, your BMI is, followed by the BMI value you get by calling the function BMI and by passing the user height and user weight values (collected in task 3) as parameters. Task 6: Go back to code for Task 3 and put the entire code that you have already written as a try block Just above the try keyword, add a comment: Task6 Add a comment: Enhancing task 3 so it can handle exceptions After the try block, and before Task 4, add three except blocks to catch these errors: Value Error ZeroDivisionError, any other exception. In each except block, you should have a print statement that prints the appropriate error message and a quit() statement, so that the program quits after displaying the error message Test the exception situations by not providing a value to weight or height; providing a height of 0; providing a non-numeric value to height or weight

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

What are the general types of interviews? Explain each.

Answered: 1 week ago