Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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 email the lecture presenter.

2 Psuedo Code

3 Real Code

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

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

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

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

8 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

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

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

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

12 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

13 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

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

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

16 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

17 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?

18 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

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

20 For Loop Two Main components: – Iterator Variable – Range

21 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

22 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]

23 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

24 Visual Representation G A T T A C A

25 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

26 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

27 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

28 Real Code

29 Better Real Code

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


Download ppt "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."

Similar presentations


Ads by Google