Question: Please use the programming language called Python ALL CODE SHOULD CONTAIN 3 LINES AT THE TOP: # Your Name # CSP 17 # Assignment name
Please use the programming language called Python
ALL CODE SHOULD CONTAIN 3 LINES AT THE TOP: # Your Name # CSP 17 # Assignment name Try-Except In the examples we have looked at we have always used the int() or float() functions on the input statement. This is not the only way to use those function. This video will provide some clarification about how a try/except block works (the video talks about 3 error types...do NOT worry about 3 types) for instance: userin = '3' pay = payrate / int(userin) The value is accepted by the input statement - then when it is used in the calculation we add the int() function. For this assignment: 1. assign a string value, that contains a number, to a variable named mylnput o have one statement that converts the input to an int and attempts to divide another number by mylnput(see the example above) o have another statement that converts the input to an int and tries to "add" it to a string. For example: name = 'Pat' + mylnput - this will generate a TypeError. 2. Also - since the second part of #1 generates an error - encode that statement in a try/except block. o create an exception for an error with appropriate error messages. Submit your .py file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
