Question: ALL CODE SHOULD CONTAIN 3 LINES AT THE TOP: # Your Name # CSP 17 # Assignment name Try-Except In the examples we have looked
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: assign a string value, that contains a number, to a variable named myInput have one statement that converts the input to an int and attempts to divide another number by myInput(see the example above) have another statement that converts the input to an int and tries to "add" it to a string. For example: name = 'Pat' + myInput - this will generate a TypeError. Also - since the second part of #1 generates an error - encode that statement in a try/except block. create an exception for an error with appropriate error messages. Submit your .py file. Rubric Programming Rubric - try/except Programming Rubric - try/except Criteria Ratings Pts This criterion is linked to a Learning OutcomeCode has NO syntax errors If the code has syntax errors you need to fix them before you submit them 3 pts Total points You should make sure there are NO syntax errors.. 0 pts No Points Syntax errors keep code from running 3 pts This criterion is linked to a Learning OutcomeCode runs catching 3 fatal errors Catch the ZeroDivisionError, the ValueError, and TypeError 3 pts Total Points The code catches all 3 errors 2 pts Good points Code catches 2 of the 3 errors 1 pts Low points Catches one of the 3 errors 0 pts No Points Catches none of the 3 errors 3 pts This criterion is linked to a Learning OutcomeCode produces proper output The error statements need to match the proper error: divide by zero, type error and value error. 3 pts Total Points All 3 of the error messages are correct. 2 pts Good points Only 2 of the 3 error messages are correct. 1 pts Low points Only 1 of the error messages are correct. 0 pts No Points None of the error messages are correct. 3 pts This criterion is linked to a Learning OutcomeCode meets requirements What does the assignment called for? Read and understand the problem and make sure you address all of the requirements. Make sure your code contains: Your name, Class, Assignment is at the top of your code. 6 pts Total points Code addresses all of the requirements and runs correctly 3 pts Good points The code runs, but one or two of the requirements are not addressed in the code. 0 pts No Points major parts of the assignment are not addressed in this code. 6 pts Total Points: 15
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
