Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To date, we haven't talked too much about handling possible input errors resulting from a user either accidentally or purposely entering incorrect data that is

To date, we haven't talked too much about handling possible input errors resulting from a user either accidentally or purposely entering incorrect data that is used by the program. This discussion will allow you to take some of your previous code from week 1 or week 2 and make adjustments such that input errors are handled gracefully.

Using code you developed in week 1 or week 2 and the guidance found in this document:

http://easypythondocs.com/validation.html

use one of the two methods suggested along one or more of the validation techniques provided and fix your code to gracefully and securely handle user input errors.

Just pick a smaller section of the code to fix. Provide the code before and after the fix. Be sure to demonstrate the new fix works as expected by providing screen captures.

Interact with one student and try their code fix. Comment on which method and techniques were used. Make adjustments and experiment to further demonstrate your understanding of their implementation.

This is the students code that needs adjustments.

# SDEV 300 # Week 3 Discussion """Updated Week 1 Discussion to showcase input validation""" import math

NAME = "Travis Mason" print(f"Hello, this is {NAME}'s Week 3 Discussion") while True: try: NUM = int(input("Please input a number to be squared & shown the square root: ")) NUM_SQUARED = math.pow(NUM, 2) NUM_ROOT = math.sqrt(NUM) break except ValueError: print("Invalid input, please enter a valid input: ")

print(f"{NUM} squared is {NUM_SQUARED} & the square root of {NUM} is {NUM_ROOT}")

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

Step: 3

blur-text-image

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

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions