Trace Tables In today’s lesson we will look at:

Slides:



Advertisements
Similar presentations
LOOPS Loops are lines of code that can be run more than one time. Each time is called an iteration and in for loops there is also an index that is changing.
Advertisements

Objectives In this chapter, you will learn about:
1 Parts of a Loop (reminder) Every loop will always contain three main elements: –Priming: initialize your variables. –Testing: test against some known.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
ITERATION. Iteration Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that.
Design Document Sample Given two concentrated circles with different radii, calculate the area which falls inside the big circle but outside the small.
Repetition In today’s lesson we will look at: why you would want to repeat things in a program different ways of repeating things creating loops in Just.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
FOP: While Loops.
7 - Programming 7P, Q, R - Testing.
Lesson 05: Iterations Class Chat: Attendance: Participation
CS1371 Introduction to Computing for Engineers
Chapter 5: Repetition Structures
( Iteration / Repetition / Looping )
Computer Programming.
Print slides for students reference
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
CMSC 120: Visualizing Information 3/25/08
Introduction to pseudocode
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Nate Brunelle Today: Repetition, Repetition
Looping and Random Numbers
© A+ Computer Science - What is a LOOP? © A+ Computer Science -
Loops CIS 40 – Introduction to Programming in Python
Computer Science Testing.
Topics Introduction to Repetition Structures
Repetition In today’s lesson we will look at:
CS150 Introduction to Computer Science 1
3.1 Iteration Loops For … To … Next 18/01/2019.
Nested Loops & The Step Parameter
Loop Strategies Repetition Playbook.
Computing Fundamentals
Global Challenge Walking for Water Lesson 2.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
Let’s all Repeat Together
ICT Programming Lesson 3:
For Loops (Iteration 1) Programming Guides.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
More Repetition While and For loop variations
CISC101 Reminders All assignments are now posted.
Flowcharts and Pseudo Code
For loops Taken from notes by Dr. Neil Moore
Global Challenge Walking for Water Lesson 2.
Chapter 4: Repetition Structures: Looping
Global Challenge Walking for Water Lesson 2.
Chapter 2: Input, Processing, and Output
Global Challenge Walking for Water Lesson 2.
Print the following triangle, using nested loops
Global Challenge Walking for Water Lesson 2.
Announcements Lab 3 was due today Assignment 2 due next Wednesday
For Loops Pages
Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Software Development Techniques
GCSE Computing.
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

Trace Tables In today’s lesson we will look at: what we mean by a “dry run” the purpose of a “trace table” an example of how to use a trace table to test a program

Dry Run When you create a program, it’s easy to miss something out, or, when counting, to go too far or stop too soon. Testing with sample data helps to identify such problems. Sometimes programmers will test their program without actually running them – they will look at their code and work out the values of the variable on each line, or for each repetition of a loop. Testing in this way is known as a dry run. The dry run can be based on a flowchart, pseudocode, or the actual code in your chosen programming language.

Trace Table One of the most common way to record the results of a dry run is in a trace table. A trace table has a column for each of your variables, and sometimes an additional column for OUTPUT, depending on the purpose of the program. There will be a row for each line, or iteration, of the code that you want to test – e.g. if a loop repeats ten times, there will be ten rows in the table. The programmer works out (manually) what the values of the variables should be at each stage and puts the values in the table. Remember that variables can be strings, Boolean, etc., so the value won’t always be a number.

Example Here is a sample program: Here is what the trace table would look like: y = 3 for x = 1 to 4 y = y + x next print y y = 3 for x in range(1,5) y = y + x print(y) X Y OUTPUT 1 3 2 4 3 6 4 9 4 13 13