Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Selection: Validating User Input Goal of Part 2: Experience with implementing control structures from a flow chart for the purpose of user validation. Requirements Did

Selection: Validating User Input Goal of Part 2: Experience with implementing control structures from a flow chart for the purpose of user validation. Requirements Did you come prepared? o Control Structures - Selection videos, ideally all done! Collaboration. o You will be discussing and working together in small groups, hopefully the same as last time (attendance and technology permitting!). o Someone will submitting a completed Python code file for marks include all group members names! Validation Code Example Using isnumeric() # Display message: "Please enter the number of sales for this salesperson: " # Attempt to store the user input in variable sale_amount sale_amount = input('Please enter the number of sales: )) if sale_amount.isnumeric(): sale_amount = int(sale_amount) isvalid = True else: isvalid = False # If sale_amount was not stored successfully if not isvalid: # display message, "Sorry, the number of sales must be a whole number" print('Sorry, the number of sales must be a positive whole number.') else: # Otherwise, carry on with processing/output Validation Code Example Using Try / Except # Display message: "Please enter the gross sales for this salesperson: $" # Attempt to store the user input in variable gross_sales try: gross_sales = float(input('Please enter the gross sales: $')) isvalid = True except: isvalid = False # If gross_sales was not stored successfully if not isvalid: # display message, "Sorry, the gross sales must be a positive number" print('Sorry, the gross sales must be entered as a positive number.') else: # Otherwise, carry on with processing/output

Plan to Program! With consideration to the plan developed in the previous class, code the application using Python! 1. Code your solution to the given problem based on the plan provided or your own planning notes.

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_2

Step: 3

blur-text-image_3

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions