Section 1: Fundamentals of Programming Flashcards
Chapter 1:
What is an Algorithm?
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.
Chapter 1:
What is Pseudocode?
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.
Chapter 1:
What are comments?
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.
Chapter 1:
What is a Data Type?
Data Types are different ways that data can be stored.
They allow for different manipulation.
Chapter 1:
What are the main 5 Data Types?
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]
Chapter 1:
What is Concatenation?
Joining 2 or more strings together (no space added between them).
Chapter 1:
What is Casting?
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”)
Chapter 1:
What is a Variable?
An identifier given to memory locations whose value can be changed in the runtime of the program.
Chapter 1:
What is a Constant?
An identifier given to memory locations whose value cannot be changed in the runtime of the program.
A variable that cannot be changed.
Chapter 1:
What are the advantages of using Constants?
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.
Chapter 2:
What are the 3 Programming Constructs?
Sequence, Selection, Iteration.
Chapter 2:
What is Sequence?
Multiple lines of code will be executed in order.
Chapter 2:
What is Selection?
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.
Chapter 2:
What is Iteration?
Similar to Selection, the program will branch to a previous point in the program, based on a condition.
The same idea as recursion.
Chapter 2:
What are the relational operators?
== OR = Equal to != OR <> Not equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to
Chapter 2:
What is the most common example of Selection?
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.
Chapter 2:
What is a nested If statement?
An If statement inside an If statement.
```
IF condition1 THEN
IF condition2 THEN
this is nested
ENDIF
ENDIF
~~~
Chapter 2:
What is Iteration?
Similar to Selection, the program will branch to a previous point in the program, based on a condition.
The same idea as recursion.
Chapter 2:
What is the difference between Switch Statements and Case Statements.
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
Chapter 2:
What is the most common example of Selection?
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.
Chapter 2:
What is a nested If statement?
An If statement inside an If statement.
```
IF condition1 THEN
IF condition2 THEN
this is nested
ENDIF
ENDIF
~~~
Chapter 2:
If statements are the most common application of Selection.
What are the other common ones?
Switch Statements.
Case Statements.