1 / 17

Starter

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".

duscha
Télécharger la présentation

Starter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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"

  2. 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?

  3. 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

  4. 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

  5. Errors in programs and being able to handle them. There are basically 3 types Of error… • Logic • Syntax • Runtime

  6. 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.

  7. What errors? print hello world

  8. What errors? Name = 'Al' print(‘You can call me ' + name)

  9. What errors? spam = 'THIS IS IN LOWERCASE.' spam = spam.lowerr()

  10. What errors? x = 3 y = 4 average = x + y / 2 print(average)

  11. What errors? spam = ['cat', 'dog', 'mouse'] print(spam[6])

  12. 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.

  13. Odd task alert Go away and try to make mistakes: Make an example of: A runtime error A syntax error A logic error

  14. Trace Table • A technique used to test algorithms to see if any logic errors occur when the algorithm is processed.

  15. Testing for errors before and during the coding stages

  16. Testing for errors during the execution of code • Breakpoints • Steps • Watches

  17. Activity 4.1 and 4.2 • 4.3 • 4.4 • 4.5 and 4.6

More Related