Pseudocode Flashcards
Pseudocode - assign a variable (x)
x = 3
Pseudocode - cast a string varaible
str(3)
Pseudocode - cast a float variable
float(“3.14”)
Pseudocode - cast an integer variable
int(“3”)
Pseudocode - make a global variable (userid)
global userid = 123
Pseudocode - print a string (hello)
print (“hello”)
Pseudocode - gather an input (name)
name = input(“enter name: “)
Pseudocode - print (hello) 8 times
use iteration
for i = 0 to 7
print (“hello”)
next i
Pseudocode - 2 ways to ask for (password) until it matches (computer)
while answer!=”computer”
answer=input(“What is the password?”)
endwhile
OR
do
answer=input(“What is the password?”)
until answer==”computer”
Pseudocode - MOD gives the ___ - 12MOD5
remainder - 2
Pseudocode - DIV gives the ___ - 17DIV5
quotient - 3
Pseudocode - if, elif, else
if … then
…
elif … then
…
else
…
Pseudocode - how to get the length of a string (name)
stringname.length
Pseudocode - how to get a substring
string.substring(start postion, num of chara)
shows (a,b) a-b
Pseudocode - make a function (triple)
function triple (number)
return number*3
endfunction
Pseudocode - do we assume pass by ref or value
value
it will specify if relevant
Pseudocode - pass by reference
changes the variable
Pseudocode - pass by value
doesnt change variable
Pseudocode - make a procedure
Pseudocode - function
returns something
Pseudocode - procedure
executes something
no return
Pseudocode - make an array (name) with 5 names
array names[5]
name 0,1,2,3,4
Pseudocode - print the 4th name in an array
print(names[3])
Pseudocode - make a 2d array 8x8 (board)
array board[8,8]
Pseudocode - open a file (myfile) and make (x) the first line
myFile = openRead(“sample.txt”)
x = myFile.readLine()
myFile.close()
Pseudocode - open a file (myfile) and print the file out
myFile = openRead(“sample.txt”)
while NOT myFile.endOfFile()
print(myFile.readLine())
endwhile
myFile.close()
Pseudocode - write a comment (comment)
// comment
Pseudocode - do we assume methods and attributes are private or public
public
will be stated if not
Pseudocode - make a methods and attributes private and public
public and private.
private attempts = 3
public procedure setAttempts(number)
attempts=number
endprocedure
private function getAttempts()
return attempts
endfunction