3.2 Programming Flashcards
What is Declaration?
reserving space in memory for a variable
What is Assignment?
Saving a value into a variable
What is a Variable?
A named space in memory that can change
What is a Constant?
A named space in memory that can’t change
What is a Data Type?
Type of data that can be stored e.g. integer
What is Input?
What the user types in
What is Output?
What the computer displays onto the screen
What is Casting?
Changing from one data type to another
What is Concatenation?
Joining data together
What is Commenting?
Adding non-executional code to your program
Why declare a constant instead of a variable?
-To tell the programmer the constant should not change
-This way it won’t accidentally change the value of it
What are the naming conventions?
camelCase and snake_case
What is an output statement?
How are they written in VB and Pseudocode?
What the computer displays onto the screen
-VB: console.writeline(“”) OR console.write(“”)
-Psuedocode OUTPUT “”
What is an input statement?
How are they written in VB and Pseudocode?
Input statements is what the user types in.
The input can be assigned to variables.
In VB you use
{variable} = console.readline()
In Pseudocode you use
{variable} ← USERINPUT
What is the difference between Pseudocode and VB?
They use a variety of different symbols and code. For example VB uses = to assign a variable whereas Pseudocode uses ←.
Why is casting useful?
It can be used to turn a string into an integer so it can be useful for maths problems
It can also turn an integer into a string so you can add decimal places i.e. 10.00
Why is commenting useful?
It can tell the programmer what the code is doing
You can comment out code to see where it is going wrong (debugging)
Why is it important to name variables and constants as meaningful identifiers?
So you know what their purpose is.
What is selection?
Performing a logical test to see what code to execute (i.e. IF… THEN… ELSE)
What is iteration?
Repeating code
What is definite iteration?
Code that is repeated a known amount of times (i.e. FOR i ← 0 TO 9)
What is indefinite iteration?
Code that is repeated an unknown amount of times, it is repeated until a certain condition(s) is met.
(i.e. WHILE anotherGo = FALSE)
What is nested iteration?
Iteration inside of iteration
(loop inside of a loop)
What is the difference between While and Repeat Until (or Do Loop Until in VB)
While checks condition at the start
Do / Repeat Until loop checks condition at the end
What does Dim achieve in VB?
Declares a variable.
What does Const achieve in VB?
Declares a constant
What is string handling?
It is used to check and manipulate strings
What are the 2 main methods of putting variables/constants in the output statements?
Interpolation
Console.writeline($”{num1} + {num2} = {ans}”)
Braces
Console.writeline(“{0} + {1} = {2}”, num1, num2, ans)
What is Case?
Case is like an IF statement it checks a variable
It is useful at checking things that have a range (i.e. a-z or A-Z)
How do you convert a character into ASCII?
Asc(variable)
How do you convert ASCII into a character?
Chr(variable)
How do you do Random number generation (RNG) in VB?
Dim num1 as Integer
Dim num2 as Integer
Dim RanNum As New Random
num1 = ranNum.next(1, 11)
num2 = ranNum.next(1, 11)
-You have to go 1 value up to get the whole range (i.e. a six sided die would need 1,7 and that includes all 6 possible values)
What is an array?
An array is a data structure which can hold multiple values
What is an advantage of using an array?
It is more efficient than using multiple variables as it can hold multiple values under it’s indexes
What is a disadvantage of using an array?
It can only hold data type
How do you access different values in an array?
Each value has an index and you can access them through iteration.
What is a parallel array?
2 1D arrays that have related information (e.g. Student names and test score)
What is a 2D array?
It is like a 1D array except it has 2 dimensions so you use it like a grid (i.e. to get to 1 part you have to use to points (1, 2))
How do you find values in a 2D array?
You have to use nested iteration
What is the limitation of a variables, 1D and 2D arrays?
They can only be 1 data type
What is a record?
A data structure made up of fields
What is a field?
(in 3.2)
A single item of data that you want to store inside of a record
Also known as an element
What is Instantiation?
The record structure can be used multiple times
A new instance of the record structure is made for each new film
How do you create an array of records?
Declare the array as the record data type (i.e. Dim DogArray() as dog)
Each index will store a single structure so 0 will contain one dog with name, age, weight, breed etc. and index 1 will be a different dog but with the same fields.
Then you must access the different dogs by iterating through the array.
What is a Procedure?
A different part of the code that in separate from the sub main.
It can be used multiple times throughout the code
Values are passed to it from a Call
It DOES NOT return a value
What is a function?
A different part of the code that in separate from the sub main.
It can be used multiple times throughout the code
Values are passed to it from Assignment or an Output
It DOES return a Value
How do you tell the difference between a Procedure and Function?
A Procedure doesn’t return a value where as a Function does
What is a parameter?
The variables that are passed to the subroutine
What is the subroutine interface?
The very top line of a subroutine, it will tell you the parameters of the subroutine
What is a Syntax error?
Mistakes in the source code - the code can’t execute because of something that can’t be translated
It is usually a typo
It stops the code from executing
e.g. Sim a as Decimal
Sim is the syntax error as the program does not know what you mean and how to execute it
What is a Logical error?
Occurs when there is a fault in the program
The program will run but not how you expect
e.g. (the line numbers are included but are not part of the program)
1 console.writeline(a)
2 console.writeline(b)
3 console.writeline(c)
4 console.writeline(a)
5 console.writeline(e)
console.writeline(a) on line 4 is the logical error as the code will execute but it will do what isn’t expected: a should be replaced with d on line 4.
What is the scope of a Local variable?
It is declared in a subroutine so it can only be ‘seen’ by that specific subroutine
What is the scope of a Global varibale?
The whole program can ‘see’ the variable
What is a shared name?
You can use the same variable name because of the use of subroutines (you can have a total variable in the main program and in multiple subroutines, all with different values)
LEN
Calculates the number of characters in a string
(Finds the length of the string)
Returns an integer
VB - Len(password)
Pseudocode - Len(password)
MID
Extracts a given number of characters from within a string from a given position
Returns a substring
VB - Mid(password, 5, 7)
Pseudocode - Substring(5, 7, Password)
INSTR
Locates the start position of a string within a string
Returns an integer
VB - InStr(password, “123”)
Pseudocode - POSITION(Password, “123”)
Right
Extracts a certain number of characters from the right of the string
Returns a substring
VB - Right(password, 3)
Pseudocode - Need to use substring
Left
Extracts a certain number of characters from the left of the string
Returns a substring
VB - Left(password, 3)
Pseudocode - Need to use substring
Variable(position)
Extracts a character from the variable at the given position
Returns a character
VB - Variable(1)
Pseudocode - Variable[1]
Char.IsUpper
Checks if a single character is uppercase
Returns Boolean
VB - Char.IsUpper(password(0))
Pseudocode - Not in Pseudocode
Char.IsLower
Checks if a single character is lowercase
Returns Boolean
VB - Char.IsLower(password(0))
Pseudocode - Not in Pseudocode
Char.IsDigit
Checks if a single character is a digit
Returns Boolean
VB - Char.IsDigit(password(0))
Pseudocode - Not in Pseudocode
What is authentication?
Checking you are an authorised user to use the systems you are trying to access
Authentication - Something you know
Password or PIN
Authentication - Something you have
ID card
Authentication - Something you are
Biometrics (i.e. face, fingerprints)
What is 2FA?
2 Factor Authentication
Gives an added level of security by combining two methods of authentication