3.2 Programming Flashcards

1
Q

What is a variable?

A

.A named place in memory to store information
.The value of the variable can change while the programme is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a constant?

A

. A named place in memory to store information
. The information stored does not change while the programme is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why declare a constant instead of a variable?

A

. Tells the programmer the constant should not change
. So the constant does not accidentally change

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are the naming conventions?

A

camelCase and snake_case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

. What is an output statement?
. How is an output statement written in Visual Basic and Pseudo code?

A

. What appears on the screen
. In Visual Basic, you use console.writeline(“type the statement in here”)
. In Pseudo code, you use the OUTPUT statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

. What is an input statement?
. How is an input statement written in Visual Basic and Pseudo code?

A

. Input statements can be used to assign variables
. In visual Basic, you use name = console.readline()
In Pseudo code, you use name <— User Input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between assignment in Visual Basic and Pseudo code?

A

Visual Basic uses an equal sign whereas, Pseudo code uses a arrow pointing to the left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is casting?

A

Casting is when you change the data type of a variable / constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is concatenation?

A

Concatenation is joining two strings together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why is casting useful?

A

So you can convert integers to strings to use string handling or turn strings to integers to do math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is commenting?

A

Commenting is adding non-executable information to the programme

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is commenting useful?

A

It tells the programmer what the code is doing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a data type?

A

A form of data like a String, Float, Integer, Boolean, Character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can commenting be used as a debugging tool?

A

You can comment out certain parts of code to see what needs to be added or removed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why is it important to name variables and constants?

A

So you know what the function of that variable is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is decleration?

A

. Decleration is allocating a certain amount of memory to a variable or constant
. It also shows what data type should be stored into the variable / constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is selection?

A

Preforming a logical test first to see what code to execute first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is iteration?

A

Repeating code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is definite iteration?

A

code that is repeated a certain amount of time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is indefinite iteration?

A

Where the code is repeated until a condition(s) is met

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is nested iteration

A

A loop inside a loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the difference between While and Repeat Until?

A

. While checks the condition at the start
. Repeat Until checks the condition at the end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does this vb command do DIM?

A

Declares a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What does this vb command do CONST?

A

Declares a constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What does console.readline() do?

A

Used to get the user input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What does console.writeline do?

A

Output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is the difference between console.write and console.writeline?

A

. Console.writeline presses enter afterwards whereas console.write doesn’t
. Console.write is used for when you want to get a user input and, it looks better

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is string handling?

A

To check and manipulate strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What are the 2 methods of putting variable/constants in your console.writline

A

. Interpolation
. Console.writeline($”this is the sum of both numbers {num1 + num2} “)
. Braces
. Console.writeline(“this is the sum of the two numbers {0}”, num1 + num2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How to use a .tostring command

A

. DIM total as decimal
Console.writeline(“the total is £”, & total.tostring(“M2”))

31
Q

What is LEN in string handling?

A

. Calculates length of a string
. Returns an integer
. LEN(variable name or form control)
. indexing starts at 1

32
Q

What is LEFT in string handling

A

Dim testString As String = “Hello World!”
‘ Returns “Hello”.
Dim subString As String = Left(testString, 5)
indexing starts at 1

33
Q

What is RIGHT in string handling?

A

Dim testString As String = “Hello World!”
‘ Returns “world!”.
Dim subString As String = Right(testString, 6)
indexing starts at 1

34
Q

What is INSTR in string handling?

A

. Identifies the first occurrence of a character or string within a string
. InStr(1, variable here, “whatever goes in here is what it checks for”)
. indexing starts at 1
. can use POSITION in pseudo code

35
Q

How can you use ISUPPER in string handling

A

Dim test As String
Dim test2 As String
test = “Hello”

    'tests if the second character in the string is uppercase
    test2 = Char.IsUpper(test, 2)
    Console.WriteLine(test2)

    'tests if the first character in the string is uppercase
    test2 = Char.IsUpper(test, 1)
    Console.WriteLine(test 2)
    Console.ReadKey() indexing starts at 1
36
Q

how can you user ISLOWER in string handling?

A

Dim test As String
Dim test2 As String
test = “Hello”

    'tests if the second character in the string is lowercase
    test2 = Char.IsLower(test, 2)
    Console.WriteLine(test2)

    'tests if the first character in the string is lowercase
    test2 = Char.IsLower(test, 1)
    Console.WriteLine(test 2)
    Console.ReadKey() indexing starts at 1
37
Q

how do you use MID in string handling?

A

Dim test As String = “Hello World 123”
Dim a As String
Dim b As String
Dim c As String

    'the first number shows what character it starts at the second number shows how many characters it goes on for

    a = Mid(test, 7, 5) 'this will output world
    b = Mid(test, 1, 11) 'this outputs Hello world
    c = Mid(test, 13, 3) 'this outputs 123

    Console.WriteLine(a)
    Console.WriteLine(b)
    Console.WriteLine(c)
    Console.ReadKey() indexing starts at 1 . you use substring in pseudo code indexing starts at 1
38
Q

how to use IsDigit in string handling

A

Dim test As String
Dim test2 As String
test = “Hello 123”

    'tests if the second character in the string is a digit
    test2 = Char.IsDigit(test, 7)
    Console.WriteLine(test2)
    'returns true

    'tests if the first character in the string is a digit
    test2 = Char.IsDigit(test, 1)
    Console.WriteLine(test 2)
    'returns false

    Console.ReadKey() indexing starts at 1
39
Q

how to use IsLetter

A

Dim test As String
Dim test2 As String
test = “Hello-123”

    'tests if the first character in the string is a letter
    test2 = Char.IsLetter(test, 1)
    Console.WriteLine(test2)
    'returns true

    'tests if the sixth character in the string is a letter
    test2 = Char.IsLetter(test, 6)
    Console.WriteLine(test2)
    'returns false

    Console.ReadKey() indexing starts at 1
40
Q

What is Case

A

. Case is like an if statement but it checks a variable
. It is strong at checking variables with ranges

41
Q

how to convert a character to ASCII

A

Asc(variable)

42
Q

How to convert ASCII to a character

A

Chr(variable)

43
Q

RNG

A

Module Module1
Sub Main()

    Dim num As Integer
    Dim aRandomNumber As New Random
    Dim counter As Integer

    For counter = 1 To 6

        num = aRandomNumber.Next(1, 100)
        Console.WriteLine("Random Number " & counter & ": " & num)

    Next
    Console.ReadLine()

End Sub

End Module

44
Q

How to use a array with numbers

A

Module Module1
Sub Main()

    Dim grade(9) As Integer
    Dim counter As Integer

    For counter = 0 To 9
        Console.Write($"Enter grade {counter + 1} ")
        grade(counter) = Console.ReadLine()
    Next

    For counter = 0 To 9
        Console.WriteLine($"Grade {counter + 1} is {grade(counter)}")
    Next

End Sub End Module
45
Q

what is a parallel array

A

2 arrays with corresponding information using the same index number. They can be different data types

46
Q

what is a 2d array

A

an array with two dimensions that can be iterated through using two counters

47
Q

How can you make a record

A

Structure dog

    Dim breed As String 

    Dim moult As Boolean 

    Dim gender As Char 

    Dim Dob As String 

End Structure
48
Q

Why are records useful

A

They can have different data types

49
Q

How can you instantiate a record

A

dim dogArray(10) as new dog

50
Q

how to declare a record

A

dim dogArray(0).moult

51
Q

What is a subroutine

A

smaller, named sections of code that are written within a larger program That can be re used
They can have parameters passed to them

52
Q

What is the difference between a procedure and a function

A

A function returns a value to the main program, a subroutine does not

53
Q

What is the structured approach to programming

A

Dividing the task into subroutines that each accomplish a task

54
Q

What are the benefits of structured programming

A

. programs are easier to read and understand
. less likely to contain logical errors
. Test each subroutine individually without interfering with the main program
. easy to re - use code with different parameters

55
Q

What is the scope of a local variable

A

it can only be used within the sub it is in

56
Q

What is the scope of a global variable

A

The whole program

57
Q

Why is it better to use local variables

A

You can use the same name in different subs and, they will free up space when the subroutine is finished

58
Q

what is a syntax error

A

When you don’t follow the rules of the language.

59
Q

What is a logical error

A

A bug in the program that causes it to not operate the way the programmer want

60
Q

What is a normal test

A

checks for normal data

61
Q

what is a boundary test

A

checks for data on the boundary numbers

62
Q

what is an invalid test

A

checks for invalid data

63
Q

what is validation

A

. checking data to see if it is acceptable
. it does not ensure the correct data is entered

64
Q

What is a range check

A

checks a range of data

65
Q

what is a type check

A

Checks for the right type of data

66
Q

what is a length check

A

checks for the length of a string or array etc.

67
Q

what is a presence check

A

checks that there is something there

68
Q

what is a format check

A

checks the format

69
Q

what is authentication

A

the process of verifying a user, process or device

70
Q

what are the three methods of authentication

A

something you know like a password
something you have like an ID
something you are like biometrics

71
Q

what is 2FA

A

2 Factor Authentication

72
Q

What is an OTP

A

One Time Password

73
Q

What are 4 methods of storing information for authentication

A

Hard Coded
Parallel arrays
2d arrays
array of records

74
Q

How can you make a program more robust

A

Add validation