Question
# In this task, you will implement a pin number obtaining function # named 'getPin' that uses IF-statements. The 'runSystem' # function below must be
# In this task, you will implement a pin number obtaining function # named 'getPin' that uses IF-statements. The 'runSystem' # function below must be called/used to test your 'getPin' function.
def runSystem(): storedPin=1234 # This variable holds the valid pin. showInformation("Welcome to the sign-in screen of the system...") enteredPin=getPin() #The error will go away when you write your function if enteredPin!=storedPin: showError("The pin you entered was not a match!") return showInformation("Pin correct! You are now logged-in to the system...") # Normally the rest of the "system's" code would go here. # Write your 'getPin' function within the designated space below so that # it asks the user to enter a pin. Remember, it is named "getPin" # because that's all that it does. I.e. it does not check if the pin # matches with the stored pin, etc. If the pin is less than 0 or # greater than 9999, you must tell the user that the entered # pin is badly formed. Finally, irrespective of whether the pin is badly # formed or not, you must return the obtained pin. # # How can we modify the code in getPin so that it always # returns a correctly formed pin? # # Note: Do not modify the runSystem function in any way. All of your # code must be inside the getPin function which you must # write in the designated space below.
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
# Write a function to calculate a person's body mass index and then # display their weight classification as a message. # The BMI is calculated as bmi=weight/(height*height). The following # table shows the messages that should be printed for various BMI # value ranges: # # Message | BMI range kg/m2 # ----------------------------------------------------------------- # You are very severely underweight | Less than 15 # You are severely underweight | From 15.0 to 16.0 # You are underweight | From 16.0 to 18.5 # You are of normal weight | From 18.5 to 25 # You are overweight | From 25 to 30 # You are moderately obese | From 30 to 35 # You are severely obese | From 35 to 40 # You are very severely obese | Over 40 # # Hints: # 1. You will need to ask the user to enter their weight and height # in meters, via the keyboard. # 2. When checking for BMI classes (using IF statements), how will you # decide where the ranges start and end, so that there are no # gaps or overlaps? # 3. This function cannot be general if you are to meet the requirements # closely.
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