Please fix of couple things in the code below. A couple of things. The input value is the waist size; the pant size is what the program is going to determine. The name valid_input is too generic. The name of the function should reflect what it does; also, start the name of the function with an action verb. For example, read_waist_size We can simplify the reading with the form : Read waist size WHILE waist size is not in the right range DO Show error message Read waist size again Simpler. By the way, the error message should let the user know how not to make the same mistake again. Something like, “This is not a correct size. Enter a value between 26 and 42.” is more helpful.     def valid_input(): while True: SizeOfPants = int(input("What pants size you are looking for: ")) if 26 <= SizeOfPants <= 42: break else: print("This is not a correct size. Try Again!!") return SizeOfPants def return_size(SizeOfPants): if 26 <= SizeOfPants < 28: return "XXS" elif 28 <= SizeOfPants < 30: return "XS" elif 30 <= SizeOfPants < 32: return "S" elif 32 <= SizeOfPants < 34: return "M" elif 36 <= SizeOfPants < 38: return "L" elif 38 <= SizeOfPants < 40: return "XL" elif 40 <= SizeOfPants < 42: return "XXL" else: return "No size Available." def main(): print("Please choose size of the pants between 26(XS) inches to 42(XXL) inches") SizeOfPants = valid_input() size = return_size(SizeOfPants) print(f"Your size is {size}") main()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please fix of couple things in the code below.

A couple of things.

  • The input value is the waist size; the pant size is what the program is going to determine.

  • The name valid_input is too generic. The name of the function should reflect what it does; also, start the name of the function with an action verb. For example, read_waist_size

  • We can simplify the reading with the form :

    Read waist size WHILE waist size is not in the right range DO Show error message Read waist size again

Simpler. By the way, the error message should let the user know how not to make the same mistake again. Something like, “This is not a correct size. Enter a value between 26 and 42.” is more helpful.

 

 


def valid_input():
while True:
SizeOfPants = int(input("What pants size you are looking for: "))
if 26 <= SizeOfPants <= 42:
break
else:
print("This is not a correct size. Try Again!!")
return SizeOfPants

def return_size(SizeOfPants):
if 26 <= SizeOfPants < 28:
return "XXS"
elif 28 <= SizeOfPants < 30:
return "XS"

elif 30 <= SizeOfPants < 32:
return "S"

elif 32 <= SizeOfPants < 34:
return "M"

elif 36 <= SizeOfPants < 38:
return "L"

elif 38 <= SizeOfPants < 40:
return "XL"

elif 40 <= SizeOfPants < 42:
return "XXL"

else:
return "No size Available."

def main():
print("Please choose size of the pants between 26(XS) inches to 42(XXL) inches")
SizeOfPants = valid_input()
size = return_size(SizeOfPants)
print(f"Your size is {size}")

main()

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY