Section 1: Fundamentals of Programming Flashcards

1
Q

Chapter 1:

What is an Algorithm?

A

A set of instructions for completing a task.
In the context of programming, it is a set of instructions that can be translated into a form that can be processed by a computer.

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

Chapter 1:

What is Pseudocode?

A

Pseudocode is a way of writing algorithms.
Pseudocode looks like a programming language, but has no set syntax, rather the programmer uses it to break down the steps of a task before writing the program.

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

Chapter 1:

What are comments?

A

Comments are sections of the Source Code that are ignored by the compiler / interpreter.

This allows for the programmer to make notes around the code to explain how it works, or what it is.

It also allows the programmer to take a section of code out of the program without deleting it. This is used in debugging and testing.

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

Chapter 1:

What is a Data Type?

A

Data Types are different ways that data can be stored.

They allow for different manipulation.

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

Chapter 1:

What are the main 5 Data Types?

A
Integers  
    - Whole numbers
Floating Point Numbers (Floats)
    - Decimal numbers
Boolean
    - True or False
    - 1 or 0
Character
    - Single alphanumeric character
    - American Standard Code for Information Interchange
    - or Unicode
    - [sometimes represented with single quote marks]
String
    - Collection of characters
    - Not always considered to be a base Data Type
    - [sometimes represented with double quote marks]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Chapter 1:

What is Concatenation?

A

Joining 2 or more strings together (no space added between them).

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

Chapter 1:

What is Casting?

A

Changing the data type of a value.

e.g.
int i = 15;
string s = (string) i

“i” is an integer (15)
“s” is a string (“15”)

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

Chapter 1:

What is a Variable?

A

An identifier given to memory locations whose value can be changed in the runtime of the program.

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

Chapter 1:

What is a Constant?

A

An identifier given to memory locations whose value cannot be changed in the runtime of the program.

A variable that cannot be changed.

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

Chapter 1:

What are the advantages of using Constants?

A

If you have a value that should change over time (e.g. VAT) but needs to NOT change during the runtime, you can use a constant to change the value in the source code in one place, rather than sifting through the whole program.

Constants can also make some operations more readable.

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

Chapter 2:

What are the 3 Programming Constructs?

A

Sequence, Selection, Iteration.

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

Chapter 2:

What is Sequence?

A

Multiple lines of code will be executed in order.

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

Chapter 2:

What is Selection?

A

Selection statements branch to a different area of the program, rather than incrementing to the next statement, based on a condition.
Often uses relational operators.

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

Chapter 2:

What is Iteration?

A

Similar to Selection, the program will branch to a previous point in the program, based on a condition.
The same idea as recursion.

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

Chapter 2:

What are the relational operators?

A
== OR =     Equal to
!= OR <>    Not equal to
>                Greater than
>=              Greater than or equal to
<                 Less than
<=                Less than or equal to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Chapter 2:

What is the most common example of Selection?

A

If statements

IF condition THEN
    (execute these instructions)
ELSE
    (execute these ones)
ENDIF

If the condition is true, do the first one.
If the condition is false, do the second one.

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

Chapter 2:

What is a nested If statement?

A

An If statement inside an If statement.

```
IF condition1 THEN
IF condition2 THEN
this is nested
ENDIF
ENDIF
~~~

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

Chapter 2:

What is Iteration?

A

Similar to Selection, the program will branch to a previous point in the program, based on a condition.
The same idea as recursion.

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

Chapter 2:

What is the difference between Switch Statements and Case Statements.

A

Switch Statements take a value (usually variable), and compares it to the first Switch value. If they are the same, the program will continue from here. If not, it will jump ahead.

Case Statements are more structured in that they will identify the starting point as where the values are equal, but also set an end point, before the next option.

Switch ("2")
{
"1": print("one"),
"2": print("two"),
"3": print("three"),
"4": print("four")
}
--> two 
--> three
--> four
Case ("2")
{
"1": print("one"),
"2": print("two"),
"3": print("three"),
"4": print("four")
}
--> two
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Chapter 2:

What is the most common example of Selection?

A

If statements

IF condition THEN
    (execute these instructions)
ELSE
    (execute these ones)
ENDIF

If the condition is true, do the first one.
If the condition is false, do the second one.

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

Chapter 2:

What is a nested If statement?

A

An If statement inside an If statement.

```
IF condition1 THEN
IF condition2 THEN
this is nested
ENDIF
ENDIF
~~~

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

Chapter 2:
If statements are the most common application of Selection.
What are the other common ones?

A

Switch Statements.

Case Statements.

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

Chapter 2:

What are the boolean operators and what do they do to conditions?

A

AND, OR, NOT.

They can make conditions more complex.
NOT - by inverting the condition.
AND/OR - by combining conditions together.

24
Q

Chapter 2:

What is the boolean order of operations?

A

NOT, AND, OR.

25
Q
Chapter 2:
The NOT operator can often be replaced by changing the Relational Operator.
What are the equivalents to:
(a) NOT (a == b)
(b) NOT (a > b)
A

(a) (a != b) OR (a <> b)

b) (a <= b

26
Q

Chapter 2:

Write (a XOR b) in terms of NOT, AND, and OR.

A

(a AND NOT b) OR (NOT a AND b)

27
Q

Chapter 3:

What are the 2 categories and 3 types of Loops?

A
Indefinite
    - While Loops
    - Repeat Until Loops
Definite
    - For Loops
28
Q

Chapter 3:

What are the two properties of a While Loop?

A

The expression controlling the repetition of the loop must be a Boolean.

The expression must be tested at the start of the loop.

29
Q

Chapter 3:

What are the two properties of a Repeat Until Loop?

A

The expression controlling the repetition of the loop must be a Boolean.

The expression must be tested at the end of the loop. (It will always run at least once).

30
Q

Chapter 3:

When are For loops useful?

A

When you know (or have stored) the exact number of times you want the loop to iterate.

31
Q

Chapter 3:

What is it called when we have a loop inside of another loop?

A

A nested loop.

32
Q

Chapter 4:

What is a Data Structure?

A

A collection of elementary data types and built-in methods.

A more complex / specific way of storing data.

33
Q

Chapter 4:

What is an Array?

A

A collection of values of the same Data Type.

34
Q

Chapter 4:

What is a List?

A

A collection of values that can be of different Data Types.

35
Q

Chapter 4:

What is the difference between an Array and a List?

A

All items in Arrays must be of the same data type, where lists can have different types at different locations.

Arrays are static, where Lists are dynamic.
Arrays must be created with a set size and the size cannot change. Lists can be created with or without values, and values can be added or removed from it.

36
Q

Chapter 4:

What is a 2 Dimensional Array?

A

An Array of Arrays.
An Array where you have Arrays instead of values.
This has a grid- or table-like effect.

37
Q

Chapter 4:

How can 2 Dimensional Arrays be indexed?

A

Array[x][y]
Array[x, y]
Array(x, y)

38
Q

Chapter 4:
What is an Index?
[In reference to Data Structures]

A

A location in an Array or List.

Array = [ 1, 2, 3 ]

print( Array[0] )
» 1

39
Q

Chapter 5:

What is a Subroutine?

A

A block of code which can be called at different parts of the program by an identifier.

40
Q

Chapter 5:

What are the two types of Subroutine?

A

Procedures,

Functions.

41
Q

Chapter 5:

What is the difference between Procedures and Functions?

A

Both have an identifier and might take parameters.

Procedures do not return a value back to the point in the program where the subroutine was called. Functions do return a value.

42
Q

Chapter 5:
What are the two types of variable parameter?
What is the difference when using them?

A

Pass in Value of variable.
Pass in Reference to variable.

When passing in Values, changing the value of the local variable does not effect the original variable.
When passing in a Reference, the value of the original variable can be changed.

43
Q

Chapter 5:

What is a Global Variable?

A

A variable that is accessible from any point in the program.

44
Q

Chapter 5:

What is a Local Variable?

A

A variable that is only accessible inside of a subroutine, and that only exists for the duration of the subroutine.

45
Q

Chapter 5:

Why are Local Variables useful?

A

They allow you to encapsulate a subroutine, making it easier to bug fix, as the contents cannot effect other parts of the program.

They allow you to reuse variable identifiers. While this is not necessarily optimal (it is often good to be able to isolate a variable by unique identifier), it can help reduce errors.

They allow for Data Hiding, so that sensitive information can be available from the least amount of places.

46
Q

Chapter 5:

What is Modular Programming?

A

Where the problem / task is split into subroutines that can handle different parts of the problem / task.

47
Q

Chapter 5:

What are the advantages of using Subroutines?

A

Subroutines are chunks of code that can be understood more easily than a single large program.

Subroutines can be tested independently, making the program easier to debug.

Subroutines can be reused in other programs that require the same functionality.

Subroutines allow for multiple programmers to work on the same project, as they can be used and applied to a larger task without knowledge of implementation.

Larger projects become easier to monitor and maintain.

48
Q

Chapter 6:

What is a Record?

A

A record is a collection of fields defining an entity.

49
Q

Chapter 6:

What are the 3 access modes for text files?

A

Read
Append
Write

50
Q

Chapter 6:

When reading from a text file, what are the two common methods?

A

Return the whole file with one statement.

Return the next line / record in a statement.

51
Q

Chapter 6:

In stored records, how are fields commonly separated?

A

Using commas in a CSV (Comma-Separated Values) file.

52
Q

Chapter 6:

How would you overwrite a record in an existing text file?

A

Open the file for reading and writing.
Search through the file to find the record you want.
Write a new record to that position.

53
Q

Chapter 6:
What are the other types of files often read and written to in Programs?
(Other than text files.)

A

Binary Files.

54
Q

Chapter 6:

What do you need to know when accessing a binary file?

A

How many bits / bytes correspond to each value.

Binary files can store multiple data types, but different data types require a different number of Bits.

55
Q

Chapter 6:

What is Exception Handling?

A

If a program may fail and crash at a certain point, we can prevent the program from closing and redirect it to a different path.

56
Q

Chapter 6:

What are some common errors to be Handled?

A

Trying to read a non-existent text file.
Trying to convert a non-numeric string into an integer or float.
Trying to perform calculations on non-numeric values.
Trying to divide by 0.