Sequences, Modules and Variables David Millard

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

Working With Algorithm and Flowcharts
Slide 1 Today you will: Review knowledge and understanding of systems Understand what a system is and what it consists of Apply this understanding by working.
Let’s Make Macaroni and Cheese This power point book was made by Holly Cooper, Ph.D.; Texas School for the Blind and Visually Impaired Outreach.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Basic Programming Concepts INTRO TO PROGRAMMING. Questions to answer  What is a computer program?  What are computer instructions  How is a program.
H OW TO MAKE A CUP OF T EA ! By Paris Bell. Safety Instructions Equipment Ingredients Instructions Instructions (continued) Tips.
Unit 7.6 Lesson 2 Goals Identify and use flowchart symbols. Plan a sequence of events and incorporate them into a flowchart. Create a simple flowchart.
Basics of Computer Programming Web Design Section 8-1.
Tutorial #6 PseudoCode (reprise)
 Draft timetable has the same times as this semester: - ◦ Monday 9:00 am to 12:00 noon, 1:00 pm to 3:00 pm. ◦ Tuesday 9:00 am to 12:00 noon, 1:00 pm.
SDP Languages and Environments. Types of Languages and Environments There are 4 main types of language that you must be able to describe at Higher level.
Tutorial #7 Flowcharts (reprise) Program Design. Introduction We mentioned it already, that if we thing of an analyst as being analogous to an architect,
Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.
CMT1000: Introduction to Programming Ed Currie Lecture 2A: Pizza.
CS 201 Functions Debzani Deb.
Programming Fundamentals (750113) Ch1. Problem Solving
Problem Solving for Programming Session 3 Dealing with Sequence, Choice and Repetition.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
CS001 Introduction to Programming Day 5 Sujana Jyothi
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1.
Selection: IF Statement Damian Gordon. adsdfsdsdsfsdfs dsdlkmfsdfmsdl kfsdmkfsldfmsk dddfsdsdfsd.
A PowerPoint about Algorithm’s. What is an algorithm?  a process or set of rules to be followed in calculations or other problem-solving operations,
A PowerPoint about Algorithm’s. What is an algorithm? A list Of cammands / instructions to do a tasks.
‘How to make perfect English tea’ Ewa Pacykowska.
For this unit, you will develop a new swimming / leisure business. 2. You will need to think of a name & concept for the business. 3. Over the.
Top-Down Design Damian Gordon. Top-Down Design Top-Down Design (also known as stepwise design) is breaking down a problem into steps. In Top-down Design.
How to make a Perfect Cup of Tea Supplies Kettle Ceramic tea-pot Large ceramic mug and spoon Microwave oven.
A PowerPoint about Algorithm’s. What is an algorithm? A step by step process of instruction.
Slide 1 What makes up an information system? Input Process Output Temperature and rainfall from a variety of places Analyse the information and present.
By Zoe Cornell. Mug Kettle Tea bag Milk Sugar Pour water into the kettle and switch it on.
Learn about the system life cycle Plan the outline of your project
Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its.
Mug Tea bag Kettle Milk Sugar (only if you like it in your tea) A spoon Biscuits A plate for the biscuits.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
Submitted To: Rutvi sarang Submitted By: Kushal Bhagat.
Algorithms and Pseudocode
Computer Control Using computers to do tasks. What are Computers used for? ringing your alarm clock. microwaving your breakfast checking for text messages.
Pseudocode Skill Area Materials Prepared by Dhimas Ruswanto, BMm.
1 OOAD Mehwish Shafiq. 2 The Requirements specification must provide sufficient information to enable the system to be constructed “ successfully. ” Functional.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Comp1004: Programming in Java II Computational Thinking.
Today… Functions, Cont.: –Designing functions. –Functional Decomposition –Importing our own module –A demo: Functional solution to assignment 2. Winter.
Algorithms and Flowcharts
HOW TO MAKE A GOOD CUP OF TEA SKW 3061 ENGLISH WORKPLACE MISS GURMINDERJEET KAUR MOHAMAD SHAZRYL B. MOHD SHUKOR B01SPS13F
Algorithms 1: Sequences and Modules Yvonne Howard & Rikki Prince
Control Structures: Conditionals, If/Else and Loops David Millard
Building Good Solutions David Millard
Quick Plenaries.
Software Development.
Introduction to programming
FLOWCHARTS Part 1.
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Introduction to Computer Programming
Yenka Portfolio Level for this topic: Student Name : My Levels
Algorithms Today we will look at: what the word algorithm means
Algorithms Y10 Introduction.
Comp1202: Building Better Programs
Programming Languages
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
“In the midst of chaos, there is also opportunity” - Sun Tzu
Process/ Instruction Writing
A programming language
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Speaking Presentation
“In the midst of chaos, there is also opportunity” - Sun Tzu
Presentation transcript:

Sequences, Modules and Variables David Millard

Overview Pseudocode What are Modules? Variables Parameters

Pseudocode “Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading” - Wikipedia “A notation resembling a simplified programming language, used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language” - Oxford English Dictionary

Pseudocode “Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading” - Wikipedia “A notation resembling a simplified programming language, used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language” - Oxford English Dictionary

Pseudocode “Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading” - Wikipedia “A notation resembling a simplified programming language, used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language” - Oxford English Dictionary

Pseudocode “Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading” - Wikipedia “A notation resembling a simplified programming language, used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language” - Oxford English Dictionary

Example: Making a Cup of Tea Get into small groups of 3 or 4 and write down the steps that you need to do in order to make a cup of tea Use a sequence of simple statements like ‘Boil Water’ or ‘Put Milk in Cup’ Try and put down an appropriate level of detail so that a person could follow your instructions unambiguously Can you group certain steps together (for example, are the first few about preparation)? Give these groups sensible names.

Swap with Another Group Take a look at the tea-making instructions of another group Annotate their instructions if: ▫Any instruction is ambiguous ▫They have missed something out ▫They have made an assumption ▫They have created a group that doesn’t make sense to you Also if they have done anything you really like :-)

Go Back to Your Own Instructions Take a few moments to see what they have said ▫Are the comments fair? ▫Any unexpected ones? ▫Would you make any changes now you have seen someone else’s instructions?

Writing Sequences is Easy… … But getting the sequence right is hard Often the specification is inadequate ▫It is easy to make assumptions without realising it Making it complete is challenging ▫Making sure not to miss smaller, less-obvious steps ▫Creating unambiguous instructions Machines are very unforgiving, they do exactly what you ask – nothing more, nothing less

Example: Making a Cup of Tea Make a Cup of Tea Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User Pseudocode Assumptions?

Example: Making a Cup of Tea Make a Cup of Tea Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User Pseudocode Assumptions: Electric Kettle User wants Milk and Sugar Only making 1 cup of tea Nothing goes wrong! Assumptions: Electric Kettle User wants Milk and Sugar Only making 1 cup of tea Nothing goes wrong!

Modules Modules break an algorithm into logical parts (like your groups) ▫Helps with Clarity and Understandability Modules can be reused ▫Within the same algorithm ▫In a different algorithm In Programming Modules can be called: ▫Sub-routines (in older languages) ▫Functions(in procedural languages like C) ▫Methods(in object oriented languages like Java)

Example: Making a Cup of Tea Make a Cup of Tea Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User

Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot Example: Making a Cup of Tea Add Tea, Milk and Sugar to Cup Make a Cup of Tea Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User

Example: Making a Cup of Tea Make a Cup of Tea Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot Add Tea, Milk and Sugar to Cup Give Cup of Tea to User Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User

Variables Variables are named items in an algorithm that can take a variable value For example: ▫n_guests and n_biscuits are variables Offer guests biscuits n_guests = the number of guests n_biscuits = the number of biscuits they each want Open biscuit barrel Put (n_guest * n_biscuits) on a plate Offer plate around

Parameters Parameters are variables that are passed to a module and are used inside like variables For example: ▫n_guests and n_biscuits are parameters Be hospitable Welcome 4 relations Offer guests biscuits(4,1) Wait for relations to leave Welcome best friend Offer guests biscuits(1,3) Offer guests biscuits(n_guests, n_biscuits) Open biscuit barrel Put (n_guest * n_biscuits) on a plate Offer plate around

Where are the Variables and Parameters? Make a Cup of Tea Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot Add Tea, Milk and Sugar to Cup Give Cup of Tea to User Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User

Where are the Variables and Parameters? Make a Cup of Tea Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot Add Tea, Milk and Sugar to Cup Give Cup of Tea to User Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User

Where are the Variables and Parameters? Make a Cup of Tea Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot (2) Add Tea, Milk and Sugar to Cup (1) Give Cup of Tea to User Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot (n_min) Put Tea in Pot Put Boiling Water in Pot Wait n_min Minutes Add Tea, Milk and Sugar to Cup (n_sugars) Put Milk in Cup Pour Tea in Cup Put n_sugars Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User

Summary Pseudocode ▫High level description of algorithm… ▫… intended for human reading… ▫… but structured like a programming language Modules (subroutines/ functions/ methods) ▫Break down bigger algorithms into chunks ▫Improves Clarity and Reuse Variables and Parameters ▫Are named things with a value (like in algebra) ▫Can make algorithms more flexible ▫Can also improve Reuse