Pseudocode Key Revision Points.

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved Control Structures 3 control structures –Sequential structure Built into Python –Selection structure The.
Advertisements

©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Loops – While, Do, For Repetition Statements Introduction to Arrays
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Lists in Python.
Copyright © Nancy Acemian 2004 For Loops-Break-Continue COMP For loop is a counter controlled loop. For loop is a pretest loop. Used when number.
Fundamental Programming: Fundamental Programming Introduction to C++
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Algorithms and Pseudocode
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
Today… Preparation for doing Assignment 1. Invoking methods overview. Conditionals and Loops. Winter 2016CMPE212 - Prof. McLeod1.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Python Fundamentals: Complex Data Structures Eric Shook Department of Geography Kent State University.
PH2150 Scientific Computing Skills Control Structures in Python In general, statements are executed sequentially, top to bottom. There are many instances.
Programming revision Revision tip: Focus on the things you find difficult first.
1 C++ Programming C++ Basics ● C++ Program ● Variables, objects, types ● Functions ● Namespace ● Tests ● Loops ● Pointers, references.
More about Iteration Victor Norman CS104. Reading Quiz.
ECE Application Programming
Test 2 Review Outline.
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
3.1 Fundamentals of algorithms
I/O Streams File I/O 2-D array review
Topic: Iterative Statements – Part 1 -> for loop
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Java for Beginners Level 6 University Greenwich Computing At School
EGR 2261 Unit 10 Two-dimensional Arrays
Arrays.
Introduction to Python
EECs 183 Discussion 10 Hannah Westra.
GC211Data Structure Lecture2 Sara Alhajjam.
ICS103 Programming in C Lecture 3: Introduction to C (2)
CSC 108H: Introduction to Computer Programming
Lecturer CS & IT Department UOS MBDIN
Engineering Innovation Center
CS 1430: Programming in C++.
Arrays, For loop While loop Do while loop
Arrays An Array is an ordered collection of variables
Learning to Program in Python
Introduction to pseudocode
Chapter 3: Introduction to Problem Solving and Control Statements
CS190/295 Programming in Python for Life Sciences: Lecture 6
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Topic 1: Problem Solving
ARRAYS 1 GCSE COMPUTER SCIENCE.
More Looping Structures
Programming 2 Decision-Making.
Logical Operations In Matlab.
Programming We have seen various examples of programming languages
Data Types and Data Structures
CISC124 Labs start this week in JEFF 155. Fall 2018
ARRAYS 2 GCSE COMPUTER SCIENCE.
EECE.2160 ECE Application Programming
CMPE212 – Reminders The other four assignments are now posted.
Lecture 1 Review of 1301/1321 CSE /26/2018.
Functions continued.
Python Basics with Jupyter Notebook
Arrays Arrays A few types Structures of related data items
Fundamental Programming
Comparing Python and Java
More Looping Structures
C++ Array 1.
CISC101 Reminders Assignment 3 due today.
Class code for pythonroom.com cchsp2cs
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
Lecture 1 Review of 1301/1321 CSE /26/2018.
Functions John R. Woodward.
COMPUTING.
Presentation transcript:

Pseudocode Key Revision Points

NOTE The basic syntax you’ll need in your exam is provided in this presentation Practice writing pseudocode is just as (more!!!) important than knowing the syntax Use the past paper practice questions provided to develop your skills!

PSEUDOCODE Used by programmers to write algorithms/ plan programs Not a real programming language (although it contains “program like” syntax) Can be translated into any programming language

INPUT/OUTPUT Equivalent to input and print in Python. Don’t forget input always needs to be assigned somewhere i.e. a variable OUTPUT “Hello Bert” OUTPUT “Which way do you want to go?” direction  USER INPUT Distance  INT(USER INPUT)

ASSIGNMENT Use an arrow to indicate assignment. Equivalent to using a single = sign in Python Arrow always points to the left! Indicating the variable type is optional but if in doubt do it! INT x  42 STRING user  “Bert” CHAR initial  ‘A’ BOOL gameOver  TRUE STRING choice  USER INPUT INT choice  INT(USER INPUT)

CONDITIONALS Equivalent to if/elif/else in Python Must have an END IF Example: IF name = “Bert” THEN OUTPUT “Hello Bert” ELSE IF name = “Fred” THEN OUTPUT “Hello Fred” ELSE OUTPUT “Who are you?” END IF Note the single = sign in if/elif part. It’s the comparison operator NOT the assignment operator. Equivalent to == in Python

NESTED CONDITIONALS Must have two (or more) END IF statements – one for each IF Example: IF age < 18 THEN OUTPUT “Discount” ELSE IF age > 65 THEN OUTPUT “Full price” END IF

ITERATION - FOR Python – for i in range(0,10): Pseudocode – FOR i  0 TO 9 DO Code inside the for block should be indented Don’t forget END FOR For nested loops you need multiple END FORs

ITERATION - WHILE Python: while x<=100: Pseudocode: WHILE x <= 100 DO Code inside the for block should be indented Don’t forget END WHILE For nested loops you need multiple END WHILEs

ARRAYS Indexing can start at 0 or 1. AQA often uses 1. Examples below make this assumption Declare and initialise an array INT myArray  [5,3,2,7] Reassign values in an array myArray[2]  6 myArray[3]myArray[3]+4 Access values in an array OUTPUT myArray[1] myNum  myArray[2]

2D ARRAYS Indexing can start at 0 or 1. AQA often uses 1. Examples below make this assumption Each element has a “row” and “column” index Declare and initialise a 2D array INT my2DArray  [[5,3],[2,7],[4,1]] Reassign values in an array my2DArray[2][1]  6 my2DArray[3][2]my2DArray[3][2]+4 Access values in an array OUTPUT my2DArray[1][2] myNum  my2DArray[2][2]

ARRAY NOTE There is no pseudocode for appending to (or deleting from) an array By definition an array’s size is fixed at declaration – you can’t add more elements

FUNCTIONS Must have at least one RETURN Don’t forget END FUNCTION Include the parameters and type Code inside function should be indented FUNCTION getArea(INT width, INT height) INT area  width * height RETURN area END FUNCTION

PROCDEURES Does NOT have a RETURN Don’t forget END PROCEDURE Include the parameters and type Code inside procedure should be indented Can use PROC instead of procedure PROCEDURE showArea (INT area) OUTPUT “The area is “ + STR(area) END PROCEDURE