Abstracting Decisions and Validation. Like with calculations, any logical task in a program can be represented by a function. You will design a new version of the program you created below. This new version will define and use functions for validating the user input, and looking up the value that corresponds to that valid input. Your program shall: Define a function that returns a valid user input. This function will use a while loop to make sure the sure the user enters a valid value. Define a function that accepts the user input as a paramter, uses the decision structure of the program you created in program below to return the value associated to that input. Use a meaningful name for the functions above. Define a function main() to drive the functionality of the program as it is used throughout Chapter 6 of the textbook. Run and test the program to make sure it works correctly
Abstracting Decisions and Validation. Like with calculations, any logical task in a
You will design a new version of the program you created below. This new version will define and use functions for validating the user input, and looking up the value that corresponds to that valid input.
Your program shall:
- Define a function that returns a valid user input. This function will use a while loop to make sure the sure the user enters a valid value.
- Define a function that accepts the user input as a paramter, uses the decision structure of the program you created in program below to return the value associated to that input.
- Use a meaningful name for the functions above.
- Define a function main() to drive the functionality of the program as it is used throughout Chapter 6 of the textbook.
- Run and test the program to make sure it works correctly
Summary
The program calculate a waist measurement in inches, and
prints the corresponding pant size. If the input value is outside
the table, the program shall display “No size available".
'''
#Display each size of the pants
print("Please choose size of the pants between 26(XS) inches to 42(XXL) inches")
SizeOfPants = int(input("What pants size you are looking for"))
if 26<= SizeOfPants < 28:
print("Size is XXS")
elif 28<= SizeOfPants < 30:
print("Size is XS")
elif 30<= SizeOfPants <32:
print("Your size is S")
elif 32<= SizeOfPants <34:
print("Size is M")
elif 36<= SizeOfPants < 38:
print("Your size is L")
elif 38<= SizeOfPants <40:
print("Size is XL")
elif 40<= SizeOfPants < 42:
print("Size is XXL")
else:
print("No size Available.")
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images