2.2 Programming Fundamentals Flashcards
What is 7 DIV 2?
3 - DIV means integer division in computer science.
What must happen before this line of code will execute? X = f.readLine()
f must be a pointer to an open file
What is the purpose of the WHERE structure in SQL?
to define the criteria of the records returned
how to convert a string into uppercase
string.upper()
how to find the length of a string
len(string)
how to return a number of characters from the beginning of the string
string[ : num ]
how to return a number of characters from the end of the string
string[ - num : ]
how to extract characters from the middle of a string
string[ w : z ]
starting from w, up until (not including) z
how to find the position of a string inside a string
string.find(“z”)
where z is the substring. if it is a character, the number of its position is given. if it is a string the position of the first letter is given
how to produce a random number
how to open a file
how to read from a file
x = filename.read()
contents of file is copied into x
how to write to a file
filename.write(“data to write”)
(filename is not the name of the file but the variable in the code that the file is stored in)
how to close a file
filename.close()
(filename is not the name of the file but the variable in the code that the file is stored in)
how to add an item to an “array”
array.append(item)