Presentation is loading. Please wait.

Presentation is loading. Please wait.

IST256 : Applications Programming for Information Systems

Similar presentations


Presentation on theme: "IST256 : Applications Programming for Information Systems"— Presentation transcript:

1 IST256 : Applications Programming for Information Systems
Exceptions

2 Agenda Connection Activity Teaching: Practice Activity
Quiz, Homework Check Teaching: Exceptions Practice Activity Quiz Average

3 Quiz #3, HW Check Connect Activity After you turn in the quiz,
Open Twitter Sentiment 1.0 For a Homework Check

4 Exceptions are… Exceptional
Exceptions represent a class of errors which occur at run-time. We’ve seen these before when run a program and it crashes due to bad input. And we get a TypeError or ValueError. Python provides a mechanism try .. except to catch these errors at run-time and prevent your program from crashing. Exceptions are exceptional. They should ONLY be used to handle unforeseen errors in program input.

5 Watch Me Code The need for an exception handling: Bad input
Good practice of catching the specific error

6 Try…Except…Finally try: statements-which-might throw-a-runtime-error except exceptionType: code-to-run-when-error-occurs finally: code-to-run-after-try-or-except Optional

7 Check Yourself: 90 Second Challenge
Input: “dc” X ? Y ? Z? Input “4” X? Y? Z?

8 Help me Code Old Enough to Vote, Exception Style Let’s Revisit our Program which tells you if you’re old enough to vote given you age, but now uses exceptions to handle non-integer input.

9 Now You Code Quiz Average
Write a program to read a series of quiz grades until you enter “quit” (or “Quit”, or “QUIT” – should not mater) After you enter “quit” it should print out the number of quizzes and the average quiz grade. When you enter something that is not a number, the program should say “Invalid quiz grade – please try again” BONUS: When you enter quiz grade not between 0 and 100 it should say “Invalid quiz grade – please try again”

10 Conclusion Activity NO CONCLUSION ACTIVITY THIS WEEK Your “Ticket Out”
Take out a piece of paper. Print your name at the top Write down ONE THING on the paper you learned today. My TA’s will collect your paper on the way out. The activity will be effort graded.


Download ppt "IST256 : Applications Programming for Information Systems"

Similar presentations


Ads by Google