1.2.4 types of programming language Flashcards

this deck only contains part (SLR08) of 1.2.4 as theres more stuff on paper. reference screenshots on phone for photos of example code etc (7th june 2024)

You may prefer our related Brainscape-certified flashcards:
1
Q

what is a computer program

A
  • series of statements (instructions) that are executed one after another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

all but the most trivial (insignificant) of programs tend to do what 3 things

A
  • accept input
  • process data
  • produce output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are the 3 programming constructs (used in procedural languages)

A
  • sequence
  • selection
  • iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is sequencing

A
  • executing instructions one after another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is selection

A
  • allows a program to branch and follow a different direction depending on outcome of a certain condition
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is iteration

A
  • repeating / looping sections of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how do you create an infinite loop

A

WHILE True

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

what is a FOR loop (type and what does it mean)

A
  • count-controlled loop
  • used when required number of iterations is known ahead of execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a WHILE loop (type and what does it mean)

A
  • condition-controlled loop
  • used when required number of iterations isn’t known because the variable used to determine when the iteration ends is changing within the iteration itself
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is a DO… UNTIL loop

A
  • alternative to WHILE where the code executes at least once before condition is checked
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the difference between WHILE loop and DO…UNTIL loop

A
  • WHILE loop, condition checked at start (if condition met, we may never execute the following lines of code in WHILE loop)
  • DO… UNTIL loop always executes code once before checking exit condition at end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what do programming constructs do

A
  • control flow of program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is program flow?

A

The path that a program follows as it runs from start to finish.

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

what is nesting

A
  • process of putting one statement inside another
  • this can be achieved through both iteration and selection statements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a variable?

A
  • pointer to a memory location that holds a value. It is defined by a name/label.

CAN BE CHANGED WHILE THE PROGRAM IS RUNNING.

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

What is a constant?

A
  • a memory location that holds a value. It is defined by a name/label

CANNOT BE CHANGED WHILE THE PROGRAM IS RUNNING

17
Q

what is a subroutine

A
  • block of code given a unique, identifiable name within a program
18
Q

why do we use subroutines

A
  • break down larger problem into series of smaller + more manageable problems
  • this makes code easier to write, debug and test
  • creates reusable components
19
Q

What is a similarity and a difference between a procedure and a function?

A
  • Both are blocks of code (provide structure to code) which carry out a set task
  • they are defined under a name which can be called and run simply by stating name of the function / procedure.
  • Functions return values whereas procedures only execute commands.
  • functions also create reusable program components
20
Q

what are procedures and functions similar to in OOP

A
  • methods
21
Q

what is casting

A
  • converting value into a different data type
  • e.g string to integer using command int
22
Q

Give examples of arithmetic operators.

A

+ (addition)
- (subtraction)
* (multiplication)
/ (division)
^ or ** (exponentiation)
MOD or % (remainder)
DIV or // (e.g 7 DIV 2 = 3, its the nearest integer answer)

23
Q

Give examples of comparison operators.

A

== (equal to)
!= (not equal to)
< (less than)
<= (less than or equal to)
> (greater than)
>= (greater than or equal to)

24
Q

Give examples of boolean operators.

A

AND / OR / NOT / XOR

25
Q

what do boolean expressions always equate to

A
  • True or False
26
Q

What does an assignment operator do?

A
  • assigns / supplies a value to a variable or constant
  • performed with the = symbol
27
Q

What does a compound assignment operator do?

A
  • assigns a value to a variable while also carrying out an arithmetic operation.
28
Q

what is string manipulation

A
  • act of manipulating, extracting or changing the characters in a string variable
29
Q

give some string manipulation commands

A
  • .length
  • .substring
  • .upper (returns original string in upper case)
  • .lower (returns original string in lower case)
  • .isupper (returns true if all characters in upper case)
  • .islower (returns true if all characters in lower case)
30
Q

what are the 2 string manipulations commands for ASCII

A
  • ascii = ord(“A”) which returns 65 which is the ASCII value of character
  • char = chr(65) which returns A which is the character from ASCII value
31
Q

What is string handling? (Give examples)

A
  • a set of commands which can carry out useful operations on a string data type.
    e.g. search, copy, compare, concatenate
32
Q

What is file handling?

A

A set of procedures that allow a program to create, read from and write to, open and close files that are saved in storage and not in memory.

33
Q

in summary, how do you write to a file

A
  • open file for creating/overwriting or appending
  • write data to file
  • close file
34
Q

in summary, how do you read/search data from a file

A
  • open file for reading data
  • assign Boolean variable to false to indicate end of file not reached
  • while end of file is false and search item not found: read data from file and if data matches what’s being searched for, assign data to variable or output. Then check if end of file has been reached and assign Boolean variable to be true
  • when end of file is true and search item found, close file