Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help with these questions, Thank you This exercise is based on the ex1 and ex2 from lab 2. Instead of using 2-digit integer, we
Please help with these questions, Thank you
This exercise is based on the ex1 and ex2 from lab 2. Instead of using 2-digit integer, we are going to use 3-digit integer as an input but you have to ensure a 3-digit integer is entered. Also, the type of the input value can be str or int. Consider that you, as a programmer, don't have access to the input process, and therefore, you need to use conditionals to apply your algorithms accordingly. Write a Python program that adds the digits in a 3-digit number, for example, if the input was 438 , the output should be 4+3+8=15. Note: - Consider the user can enter any number and make sure that only a 3-digits number is used for further processing, otherwise an error message is printed (for example, "The entered number is not a 3-digit integer"). - Do not change the code provided Example input 396 Example output 3+9+6=18 The starter code is given below. \# Don't change the code below import random opt = random. choice([True, False]) if opt: n = int(input ("Enter a three digit number: ")) else: n = input("Enter a three digit number: ") \# Don't change the code above \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \#Write your code below this line Exercise 2 - BMI Calculator Write a program that calculates the Body Mass Index (BMI) from a user's weight and height. 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) It should tell them the interpretation of their BMI based on the BMI value. - Under 18.5 they are underweight - Over 18.5 but below 25 they have a normal weight - Over 25 but below 30 they are slightly overweight - Over 30 but below 35 they are obese - Above 35 they are clinically obese. Example input weightheight=85=1.75 Example output Your BMI is 27.8, you are slightly overweight. The starter code is given below. H \# Don't change the code below height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg : ")) \# Don't change the code above \#Write your code below this lineStep 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