Can you pick 3 errors from this Starter Can you pick 3 errors from this Temp = input("What is the temperature in the house?") if (int(Temp) <= 15): Print ("The temperature is ", Temp, "degrees. Time to put the heating on") else: print "The temperature is ", Temp, "degrees. The heating is going off"
Can you pick 3 errors from this Starter Can you pick 3 errors from this Temp = input("What is the temperature in the house?") if (int(Temp) <= 15): Print ("The temperature is ", Temp, "degrees. Time to put the heating on") else: print ("The temperature is ", Temp, "degrees. The heating is going off“) How tedious is that?
Lesson Outcomes 2.1.3 Be able to identify differentiate between types of error in programs 2.1.4 Be able to interpret error messages and identify, locate and fix errors in a program. 2.1.7 Be able to make effective use of tools offered in an integrated development environment [watcher, break points, single step, step throughs] What causes error messages All of should be able to recall different error types All of you should be able to recall error messages in python
Making errors... Making mistakes is okay. It happens all the time! But you don’t release a game with errors http://www.bbc.co.uk/news/technology-25137093 http://www.youtube.com/watch?v=9zjGgau3iF8&safe=active
Errors in programs and being able to handle them. There are basically 3 types Of error… Logic Syntax Runtime
Errors in programs and being able to handle them. An error in the design of the program, wrong programming or wrong logic. (May not produce an error – just wrong outcome) often no obvious error is flagged up Often due to mistake in the algorithm or wrong data type. Format errors failing to follow the grammar rules of the programming language used.
What errors? print hello world syntax
What errors? Name = 'Al' print(‘You can call me ' + name) Runtime error
What errors? spam = 'THIS IS IN LOWERCASE.' spam = spam.lowerr() Runtime error
What errors? x = 3 y = 4 average = x + y / 2 print(average) http://cscircles.cemc.uwaterloo.ca/1e-errors/
What errors? spam = ['cat', 'dog', 'mouse'] print(spam[6]) Runtime error
Errors in programs and being able to handle them. Type Error Runtime NameError ZeroDivisionError KeyBoardInterrupt When a name is used that is not known about (often a variable name that is misspelt). Dividing a number by zero. When a program is interrupted from the keyboard by pressing control+c. An error occurs when the program is running. When an operation is attempt that is invalid for that type of data. Specific to python
Odd task alert Go away and try to make mistakes: Make an example of: A runtime error A syntax error A logic error
Trace Table A technique used to test algorithms to see if any logic errors occur when the algorithm is processed.
Testing for errors before and during the coding stages
Testing for errors during the execution of code Breakpoints Steps Watches
Activity 4.1 and 4.2 4.3 4.4 4.5 and 4.6