Key Terms Flashcards
What is a constant?
A variable that doesn’t change, doesn’t change in the program
What is a variable?
A value that can change value once imputed into a program
What can data values be stored as?
Constants or variables
What are the 4 types of variables?
Boolean, integers, float, and string
What is the function that changes all characters in a string to upper case?
x.upper
x being the string
What is the function that changes all the characters in a string to lower case?
x.lower
What is the function that returns all characters in a string?
x.length
x.(i) does what?
Extract the character in position (i) from string x
What does the function x.subString(a,b) do? What would the output be if this was ‘hello’?
Extracts part of the string starting at position a and with a length of b. Hello would be ‘lo’
Give an example of a cast? What is a cast?
Str(age)
Where the type of variable is stated
What is DIV?
Where the integer of a calculation is given without its remainder. E.g. 20 DIV 3 is 6
What is MOD?
What the remainder of a calculation is E.g. 20 MOD 3 is 2
What are the 3 types of loops?
While, for and if
How many dimensions of arrays are there?
3
What is an array?
A data structure that consists of a group of elements (values or variables), each identified as an index
A data structure where all the data is stored and defined under one variable
What is an algorithm?
A procedure / sequence that allows a computer to solve a problem, it is a sequence of instructions, it defines the routes through programs. A step by step set of rules for instructions
What does the while loop do?
If keeps running a program (instruction in a program) until a certain condition is met
What does the for loop do?
Set a number of cycles for that instruction / that part of the program to do before moving in. E.g. for(1,3) which would make the program run for 3 times leaving each answer in a row in an array then the program either ends or moves on once this has been met and 3 (in this example) values have been left
Iteration is what?
The act of repeating a process
What is an assignment?
The operation to change the data value of a variable, overwriting what was there before
What is the scope (of variables) ?
Whether a variable is local or global, local variables only work in the loop, procedure or class it is set in whereas global variable can be accessed from any point in the program
What is a declaration?
Declaring a name of a variable, what type it will be and where it will be stored in memory
What are operations?
Signs that give something a value compared to something else, a logical decision E.g. ==equal to, < less than, > greater than, >= greater than or equal to, <= less than or equal to, != not equal to
What does data control?
The sequence in which instructions occur
What is an iterative program?
A statement which makes a program repeat a set of instructions
What is selection?
When you select what part of the program to run, you can skip buts due to selective statements such as IF.
What is sequence?
When a program is run in sequence line by line
What is a container data type?
A data type that contains several items of data
Give 4 examples of container data types
Strings, lists, tuples and dictionary
What does mutable mean? Give examples of what is mutable
That somethings value can be changed, a list, variable and dictionary are mutable
What is a dictionary (what does it do)?
Stores data items in pairs, consisting of a key and a value. Like a printed dictionary, you look up the word (key) and find its definition (the value)
What types of checks can you do to validate the user?
Length check, type check and format check
What is a tuple?
They are very similar to list but immutable. It is a type of sequence that like a list can store items of the same or different types, can be indexed, sliced and sorted
What is a tuple written in?
Parentheses (round brackets)
What is a list?
A list is a type of sequence, like a string but can contain elements of any type. A list can store items of the same or different types, can be indexed, sliced and sorted
Can you define an empty list in python? What about a list with many elements of the same value? What do you write a list in
Yes and yes [square brackets] Empty list: aList = [ ] Repeated value: bList = [None] * 10 cList = [0] * 5