1/53
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Why do we have different data types?
So code is memory efficient, robust (hard to break) and predictable
What are integers + memory size
Whole numbers, 2 bytes
What are floats/real + memory size
Whole number with decimal part, 4 bytes
What is a character + memory size
A single ASCII character, 1 byte
What is a string + memory size
Zero or more characters - inside quote marks, 1 byte per character
What is a boolean + memory size
Values of True or False, just one bit put high level languages 1 byte
How to define constants in pseudocode
Shown in uppercase
Why use a constant instead of variable
Prevents value from being changed accidentally in code, whos programmer value should stay the same throughout the program
What does concatenating mean?
Joining together
What is casting?
Functions used to convert data types
Why is casting used?
Different data types are represented differently in binary
Function to convert data types - pseudo code
DATATYPE1_TO_DATATYPE2(datatype1), CHAR, CODE, STRING, INT
What does CHAR_TO_CODE('a') do?
Gives 97 - evaluates to the number using ASCII
What does len(string) do?
Gives length of the string
What does SUBSTRING(start/index1, end/index2, string) do?
Will output the part of the string which starts at index1 letter and ends with index2 letter
How to find the position of a character in a string? Pseudocode
POSITION(string, character)
How make a string uppercase - pseudocode?
UPPERCASE(string) or string.UPPER_CASE
Definition of sequence?
the statements are executed one by one in the order they are written in
Definition of selection?
The next statement is executed depending on whether the condition being tested is True or False
What are nested if statements?
If statements inside another if statement
What are AND, OR and NOT called?
Boolean expressions
What does AND do?
Returns true if both conditions are true
What does OR do?
Returns true if either of the conditions are true
What does NOT do?
Switches the expression from True to false and vice versa
How to generate random numbers - pseudocode?
Import random
RANDOM_INT(num1, num2)
Definition of iteration
Repetition of a section of code
When are for loops used?
When you want to execute the loop a specified number of times
What iteration are for loops?
Count controlled iteration
When are while loops used?
When you want to execute the loop while a certain condition is true
When is a condition tested in a while loop?
At the beginning of the loop
What type of iteration is a while loop?
A condition controlled loop
For loop pseudocode?
FOR...ENDFOR
While loop - pseudocode?
WHILE...ENDWHILE
When are conditions tested in a repeat until loop
At the end of the loop
Repeat until loop pseudocode?
REPEAT...UNTIL
Definition of array
A data structure that allows you to hold many items of data which is referenced by one identifier
Condition of an array?
All items of data in the array must be the same data type
Advantages of arrays?
You don't have to use lots of variables, can be used in linear search, can be used in bubble sort
Disadvantages of arrays
Have a fixed size, Inefficiency of inserting/deleting items, can be memory inefficient, has to be same data type
How to swap items in a list?
list[0], list[4] = list[4], list[0] (swaps item 0 with item 4)
How to add items to a list?
list.append(item you want to append)
How to define arrays in pseudocode?
array arrayName[number of elements in array at beginning]
INDENT arrayName
How to make a list of 5 ""
list = [""]*5
Definition of a record
a data structure consisting of a number of fields which can all be of different data types
What is a field?
A single item of data in a record
Defining a record called film - pseudocode
RECORD recordName
INDENT fieldName1: data type
INDENT fieldName2: data type
ENDRECORD
Definition of instantiation
New instances of a record structure being made for different things
Instantiation - pseudocode?
newRecord
Updating a record - pseudocode?
recordName.fieldName
What is a Two-dimensional array?
a list made up of lists/lists in a list
How are position of elements represented in two-dimensional arrays? in python
list[a][b] where a = which 1 dimensional array the element is in b = index of which element in 1D array
What does len(listName) do? listName is a 2D array
Finds number of lists in the two-dimensional array
What does len(listName[1]) do? listName is a 2D array
Used to find number of elements in the one dimensional array (highlighted by the index) in the two dimensional array
Which programming language does the index list[a,b] work in?
Python NumPy array