Programming for GCSE Topic 4.2: Faults and Debugging T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.

Slides:



Advertisements
Similar presentations
Programming for GCSE Topic 9.1: Logic Circuits T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary.
Advertisements

Programming for GCSE Topic 10.2: Designing for File I/O T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science.
Programming for GCSE Topic 3.1: If Statements in Python T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science.
VARIABLES AND DEBUGGING Beginning Programming. Assignment Statements  Used to hold values in a variable  Calculates a result and stores it in a variable.
Debugging Introduction to Computing Science and Programming I.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Section 2.4: Errors. Common errors ● Mismatched parentheses ● Omitting space after operator or between numbers ● Putting operator between operands.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
Programming for GCSE Topic 3.3: Boolean Logic and Truth Tables
Using Text, Games, and GUIs to Teach Java Barb Ericson Georgia Tech April 2006.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Homework Reading Programming Assignments
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
DEBUGGING CHAPTER Topics  Getting Started with Debugging  Types of Bugs –Compile-Time Bugs –Bugs Attaching Scripts –Runtime Errors  Stepping.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Structured programming 4 Day 34 LING Computational Linguistics Harry Howard Tulane University.
Variables "There are 10 kinds of people in the world today – those who understand binary and those who don't!” Unknown.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Problem of the Day  Why are manhole covers round?
Programming for GCSE Topic 6.2: Testing T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Introduction to Computer Programming
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Python Programming Lecture II. Data Data is the raw material that programs manipulate. Data comes in different flavours. The basic ones are called “primitive.
C OMPUTER P ROGRAMMING 1 Input and Variables. I/O S TATEMENTS : I NPUT & V ARIABLES Input is the term used to describe the transfer of information from.
Programming for GCSE Topic 8.1: Functions T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
Debugging Watch and Text Output Alice. Debugging Techniques Several techniques are helpful in eliminating errors (bugs) in programs: careful design incremental.
Programming for GCSE Topic 2.2: Binary Representation T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science.
Programming for GCSE Topic 9.2: Circuits for Adding T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.
Box Variables Prof Paul Curzon Queen Mary, University of London With support from Google, D of.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Wrapper Classes Debugging Interlude 1
Introducing Python Introduction to Python.
Topic: Python’s building blocks -> Variables, Values, and Types
Introduction to Python
Chapter 2: Input, Processing, and Output
Topic: Python’s building blocks -> Variables, Values, and Types
Testing and Debugging.
Software Design and Development
Testing Key Revision Points.
Lesson Outcomes Be able to identify differentiate between types of error in programs Be able to interpret error messages and identify, locate.
TRANSLATORS AND IDEs Key Revision Points.
Teaching London Computing
Programming for Visually Impaired Learners
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Debugging CSCE 121 J. Michael Moore.
Tonga Institute of Higher Education
Spot the bug!.
When your program crashes
Homework Reading Programming Assignments Finish K&R Chapter 1
Chapter 2: Input, Processing, and Output
Selection Statements Chapter 3.
A Level Computer Science Topic 6: Introducing OOP
A Level Computer Science Topic 5: Computer Architecture and Assembly
WJEC GCSE Computer Science
Primary School Computing
Presentation transcript:

Programming for GCSE Topic 4.2: Faults and Debugging T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London

Aims What goes wrong and when? Understanding the faults at different stages of program execution Techniques for debugging Form a hypothesis Halve the problem Debugger Principles Demo

Teaching Issue Simple errors can be disproportionately difficult at first Does it help to understand more? Teach some tactics for fixing errors The limits of ‘just changing something’ When to introduce the debugger Is it useful?

U NDERSTANDING W HAT G OES W RONG … and when

Types of Errors Syntax errors Brackets String Indentation Execution errors Names Expressions Variables Parsing Execution Program text Parsed program Output

Types of Errors Syntax The words make no sense The words do not make a sentence Execution errors I cannot understand that sentence I know what you mean, but I cannot do that Python has more execution errors Other languages have a type checker

Bugs The program works, but it isn’t the program you wanted! Enter a Binary Number> 1011 In Base 10, the number is: 31 In Octal, the number is: 0x1f In Hexadecimal, the number is: 0o37 number=int(input("Enter a Binary Number> "), 3) print("In Base 10, the number is: ", str(number)) print("In Octal, the number is: ", hex(number)) print("In Hexadecimal, the number is: ", oct(number))

Syntax Errors Strings: must close Indentation Proper boxes Brackets Must match

Execution Errors – Names Names: As variables are not declared, any name could be a variable number=int(input("Enter a Binary Number>" ), 2) print("In Base 10, the number is: ", str(number)) print("In Octal, the number is: ", oct(number)) Print("In Hexadecimal, the number is: ", hexi(nuber))

Execution Errors Names As variables are not declared, any name could be a variable Variable Must be assigned before used Expression The operator does not exist E.g. “David” – “Cameron” The operator has no answer for the values E.g. “David”[5]

D EMONSTRATIONS

Demo 1

Demo 2

T ACTICS FOR F INDING E RRORS Test often

Where is the Error? Hard to find if you are looking in the wrong place Syntax errors may ‘appear’ after real location Use comments to shrink program Look at the line number in the message Print something before error

Importance of ‘Hypothesis’ “I think the problem is …” Have an idea.. test it … revise it Alternative is to make ‘random’ changes

D EBUGGER Watch the program working

Debugger - Principles Breakpoint Stop the program in progress Observe the values of variable

D EMO OF D EBUGGER See separate demo.

Summary Finding errors is difficult Lots of errors at first Does it help to understand the types of errors Teach good habits Be systematic in finding errors Have a ‘hypothesis’ Bad habits: make changes without thought