Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there.

Slides:



Advertisements
Similar presentations
What type of data can a variable hold?
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
One Dimensional Arrays
CS110 Programming Language I
Designing Algorithms Csci 107 Lecture 4. Outline Last time Computing 1+2+…+n Adding 2 n-digit numbers Today: More algorithms Sequential search Variations.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
More loops Linag, Chpt 3, pp The do-loop continue- condition ? loop-body statements next statement false true WHILE-LOOP continue- condition? loop-body.
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
The If/Else Statement, Boolean Flags, and Menus Page 180
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Adapted from slides by Marie desJardins
The if statement and files. The if statement Do a code block only when something is True if test: print "The expression is true"
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
THE BIG PICTURE. How does JavaScript interact with the browser?
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 7: One More Loop Problem, Generating “random” values, Midterm Review.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
1 4.8The do/while Repetition Structure The do/while repetition structure –Similar to the while structure –Condition for repetition tested after the body.
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.
Data Structures and Algorithms Introduction to Algorithms M. B. Fayek CUFE 2006.
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
How to Read Code Benfeard Williams 6/11/2015 Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
1 Building Java Programs Chapter 7: Arrays These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or.
Overview of Java Loops By: Reid Hunter. What Is A Loop? A loop is a series of commands that will continue to repeat over and over again until a condition.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
1 CS161 Introduction to Computer Science Topic #8.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Computer Programming for Engineers
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
LOOPS CHAPTER Topics  Four Types of Loops –while –do…while –for –foreach  Jump Statements in Loops –break –continue 2.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
1 CSC103: Introduction to Computer and Programming Lecture No 9.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Chapter 4 Repetition Statements Program Development and Design Using C++, Third Edition.
Strings … operators Up to now, strings were limited to input and output and rarely used as a variable. A string is a sequence of characters or a sequence.
ENGINEERING 1D04 Tutorial 1. WELCOME! What we’re doing today Who am I How to do well What are computer programs Software Development Cycle Pseudo Code.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Learning outcomes 5 Developing Code – Using Flowcharts
CS1022 Computer Programming & Principles
INC 161 , CPE 100 Computer Programming
Numbering System TODAY AND TOMORROW 11th Edition
Psuedo Code.
Counted Loops.
Lecture 4B More Repetition Richard Gesick
Arrays, For loop While loop Do while loop
ARRAYS 1 GCSE COMPUTER SCIENCE.
Module 4 Loops.
Class Examples.
Let’s all Repeat Together
Flowcharts and Pseudo Code
CHAPTER 6: Control Flow Tools (for and while loops)
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
COMPUTING.
Presentation transcript:

Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there is any confusion, please the lecture presenter.

Psuedo Code

Real Code

Pseudo Code Pseudo = Fake Code = Fancy computer stuff A way to organize your program before coding it

General Guidelines Input Output Steps in between Not Language Specific Only you need to understand it Should not work

ToolBox Variables (int, float, char, string) Arrays If If-Else While loop For loop Functions

If - Else If (True or False Statement) Run Code Run More Code Else Run Other Code

Problem 1 Matt keeps getting on your computer and running your code Write a program that asks for the users name If its Matt tell him to get back to work Input: User’s name Output: Chiding Statement

Problem 1: Word Solution Load in a user name from the keyboard Check if that name is matt If it is matt, say something

Problem 1: Pseudo Code User Name = userInput(stuff) If User Name is Matt Print Boo Matt

Problem 1: Pseudo Code User Name = userInput(stuff) If User Name is Matt Print Angry Statement Else Print You do You!

Class Problem 1 Write a program that takes in a number from a user and tells them if it is Divisible by 11 Input = User Number Output = Printed statement on divisibility Hint: Mod (%) gives the remainder 5 Mod 2 = 1

Class Problem 1: Word Solution Load in a number from the user See if that number is divisible by 11 If it is tell them If it is not, tell them

Class Problem 1: Pseudo Code Solution Number = userInput(stuff) If Number Mod 11 is 0 Print Affirmative Statement Else Print Negative Statement

While While (True or False Statement) Do Code Do More Code

Problem 2 Write a program that takes in a number from a user and tells them if it is Divisible by 11 But keep asking until the user enters the number 0

Problem 2: Pseudo Code While(Number is not 0) Number = userInput(stuff) If Number Mod 11 is 0 Print Affirmative Statement Else Print Negative Statement Why will this not work?

Class Problem 2: Pseudo Code Number = 1 While(Number is not 0) Number = userInput(stuff) If Number Mod 11 is 0 Print Affirmative Statement Else Print Negative Statement

Array Cute = [‘Puppy’,’Kitten’,’Piglet’,’Tigger’] 0 indexed: indexed: indexed: cute[1] = Kitten 1 indexed: cute[1] = Puppy

For Loop Two Main components: – Iterator Variable – Range

For Loop For counter in 1 – 10 – Print “pass” + counter For i = 1, i <= 10, i = i + 1 – Print “pass” + counter For word in Words – Print word

Problem 3 You are given a DNA Sequence and have to report how many times the Motif CAT appears Input = DNA Sequence (GATTACA), CAT Output = CAT Count Hint1: A string is really just as an array of characters [‘G’,’A’,’T’,’T’,’A’,’C’,’A’] Hint2: you can take a slice out of an array – Array[2:4]

Problem 3: Word Solution Load DNA Sequence and CAT into variables Set a motif counter to 0 Iterate through DNA sequence – Pull out sets of three letters and compare to CAT – If we find CAT increment the counter Report the final count

Visual Representation G A T T A C A

Problem 3: Pseudo Code Motif = CAT DNASeq = loadFile(InputDNA) CAT_Count = 0 For i in DNASeq Range – 2 if(DNASeq i to DNASeq i+2 is CAT) CAT_Count + 1 Print CAT_Count

Class Problem 3 You are given a DNA sequence and have to determine its GC content Input = DNA sequence (GATTACA) Output = GC content Hint: You can use a For loop to iterate through the elements of an array

Class Problem 3: Pseudo Code DNASeq = loadFile(InputDNA) GC_Count = 0 For Letter in DNASeq if Letter is G or C GC_Count + 1 DNALength = length(DNASeq) GC = GC_Count/DNALength X 100% Print GC

Real Code

Better Real Code

Parting Lessons Inputs Outputs Toolbox Take Your Time Only you have to understand your pseudo code