Psuedo Code Pseudo Code Pseudo = Fake Code = Fancy
Description: Psuedo 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 compile Steps
Related Topics
Download Presentation
"Psuedo Code Pseudo Code Pseudo = Fake Code = Fancy" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide1. Psuedo Code<br>
slide2. Pseudo Code Pseudo = Fake
Code = Fancy computer stuff
A way to organize your program before coding it<br>
slide4. General Guidelines Input
Output
Steps in between
Not Language Specific
Only you need to understand it
Should not compile<br>
slide5. Steps to Pseudo Coding Step 1: Outline
Very General, Inputs to outputs
Little computer code used
Short and to the point
Step 2: Actual Pseudo Code
More line by line
Focus on variable storage and functions<br>
slide6. ToolBox Variables (int, float, char, string)
Arrays, dict/hash tables
If
If-Else
While loop
For loop
Functions
The Google<br>
slide7. Problem 1 Gregg keeps getting on your computer and running your code
Write a program that asks for the users name
If its Gregg tell him to get back to work
Input: User’s name
Output: Chiding Statement<br>
slide8. Problem 1: Outline Solution Load in a user name from the keyboard
Check if that name is Gregg
If it is Gregg, say something<br>
slide9. Problem 1: Pseudo Code User Name = userInput(stuff)
If User Name is Gregg
Print Chiding Statement to Snoop Gregg
Else
Print You do You!<br>
slide10. 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<br>
slide11. Class Problem 1: Outline 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<br>
slide12. Class Problem 1: Pseudo Code Solution Number = userInput(stuff)
If Number Mod 11 is 0
Print Affirmative Statement
Else
Print Negative Statement<br>
slide13. 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<br>
slide14. 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?<br>
slide15. Class Problem 2: Pseudo Code Number = not 0
While(Number is not 0)
Number = userInput(stuff)
If Number Mod 11 is 0
Print Affirmative Statement
Else
Print Negative Statement<br>
slide16. 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/list of characters
[‘G’,’A’,’T’,’T’,’A’,’C’,’A’]
Hint2: you can take a slice out of an array
Array[2 to 4]<br>
slide17. Problem 3: Outline Load DNA Sequence and CAT into variables
make a motif counter
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<br>
slide18. Visual Representation G A T T A C A<br>
slide19. 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<br>
slide20. Class Problem 3 You are given a DNA sequence and have to determine its GC content (percentage)
Input = DNA sequence (GATTACA)
Output = GC content
Hint: Loops are your friend<br>
slide21. Class Problem 3: Outline Load in sequence
Set up a GC counter
Loop through sequence
Compare every letter to G or C
Determine total nucleotide count
Do appropriate math to get percentage<br>
slide22. 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<br>
slide23. Real Code<br>
slide24. Better Real Code<br>
slide25. Parting Lessons Inputs
Outputs
Toolbox
Take Your Time
Only you have to understand your pseudo code<br>
slide26. Class Problem 4 You need a program that will take in a DNA sequence from a user and return the the reverse complement RNA sequence
Input: DNA sequence
Output: RNA Sequence
Hint 1: You can reverse a list, or you can loop through a list backwards
Hint2: Figuring out the complement can be done with a series of if statements<br>
slide27. Class Problem 4: Outline Load in DNA sequence
Loop through the sequence from back to front
Check identity of each letter, add its complement to new string
Remember RNA has U, not T<br>
slide28. Class Problem 4: Pseudo Code DNASeq = userInput(stuff)
RNASeq = empty list
Seq Length = length(DNASeq)
For I in range 0 to seq Length
Index = length(DNASeq) – I
If DNASeq[index] is G
RNASeq + C
Else if DNASeq[index] is A
RNASeq + U
… and so on<br>
slide29. Real Code!<br>
slide2. Pseudo Code Pseudo = Fake
Code = Fancy computer stuff
A way to organize your program before coding it<br>
slide4. General Guidelines Input
Output
Steps in between
Not Language Specific
Only you need to understand it
Should not compile<br>
slide5. Steps to Pseudo Coding Step 1: Outline
Very General, Inputs to outputs
Little computer code used
Short and to the point
Step 2: Actual Pseudo Code
More line by line
Focus on variable storage and functions<br>
slide6. ToolBox Variables (int, float, char, string)
Arrays, dict/hash tables
If
If-Else
While loop
For loop
Functions
The Google<br>
slide7. Problem 1 Gregg keeps getting on your computer and running your code
Write a program that asks for the users name
If its Gregg tell him to get back to work
Input: User’s name
Output: Chiding Statement<br>
slide8. Problem 1: Outline Solution Load in a user name from the keyboard
Check if that name is Gregg
If it is Gregg, say something<br>
slide9. Problem 1: Pseudo Code User Name = userInput(stuff)
If User Name is Gregg
Print Chiding Statement to Snoop Gregg
Else
Print You do You!<br>
slide10. 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<br>
slide11. Class Problem 1: Outline 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<br>
slide12. Class Problem 1: Pseudo Code Solution Number = userInput(stuff)
If Number Mod 11 is 0
Print Affirmative Statement
Else
Print Negative Statement<br>
slide13. 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<br>
slide14. 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?<br>
slide15. Class Problem 2: Pseudo Code Number = not 0
While(Number is not 0)
Number = userInput(stuff)
If Number Mod 11 is 0
Print Affirmative Statement
Else
Print Negative Statement<br>
slide16. 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/list of characters
[‘G’,’A’,’T’,’T’,’A’,’C’,’A’]
Hint2: you can take a slice out of an array
Array[2 to 4]<br>
slide17. Problem 3: Outline Load DNA Sequence and CAT into variables
make a motif counter
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<br>
slide18. Visual Representation G A T T A C A<br>
slide19. 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<br>
slide20. Class Problem 3 You are given a DNA sequence and have to determine its GC content (percentage)
Input = DNA sequence (GATTACA)
Output = GC content
Hint: Loops are your friend<br>
slide21. Class Problem 3: Outline Load in sequence
Set up a GC counter
Loop through sequence
Compare every letter to G or C
Determine total nucleotide count
Do appropriate math to get percentage<br>
slide22. 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<br>
slide23. Real Code<br>
slide24. Better Real Code<br>
slide25. Parting Lessons Inputs
Outputs
Toolbox
Take Your Time
Only you have to understand your pseudo code<br>
slide26. Class Problem 4 You need a program that will take in a DNA sequence from a user and return the the reverse complement RNA sequence
Input: DNA sequence
Output: RNA Sequence
Hint 1: You can reverse a list, or you can loop through a list backwards
Hint2: Figuring out the complement can be done with a series of if statements<br>
slide27. Class Problem 4: Outline Load in DNA sequence
Loop through the sequence from back to front
Check identity of each letter, add its complement to new string
Remember RNA has U, not T<br>
slide28. Class Problem 4: Pseudo Code DNASeq = userInput(stuff)
RNASeq = empty list
Seq Length = length(DNASeq)
For I in range 0 to seq Length
Index = length(DNASeq) – I
If DNASeq[index] is G
RNASeq + C
Else if DNASeq[index] is A
RNASeq + U
… and so on<br>
slide29. Real Code!<br>