Computational Thinking (II) - Programming Flashcards

1
Q

How many programming data types are there?

A

5

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

What do data types do?

A

Store data as different types

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

What happens to memory with data types?

A

Each data type is allocated a different amount of memory

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

Why is it important to use the correct data type?

A

The code is more memory efficient, robust (hard to break) and predictable when the correct data types are used

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

How can programming languages be typed?

A

Weakly typed or strongly typed

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

What are the characteristics of weakly types programming languages?

A

Weakly try to convert data types to avoid errors

*Can lead to unpredictable results

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

What are the characteristics of strongly types programming languages?

A

Strongly don’t convert data types so will produce more errors

*Give more predictable results

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

What are the 5 main data types and what are their characteristics?

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

What are the memory requirements for the 5 data types?

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

What is casting?

A

Manual conversion between data types

Can be done using int(), real() / float(), bool() and str() commands

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

In casting, what would int(“1”) achieve?

A

Converts the string “1” to the integer 1

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

In casting, what would real(1) achieve?

A

Converts the integer 1 to the real 1.0

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

In casting, what would bool(1) achieve?

A

Converts the integer 1 to the Boolean value True

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

In casting, what would str(True) achieve?

A

Converts the Boolean value True to the string “True”

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

How is casting used with ASCII and what techniques allow it to be used?

A

ASCII numbers and characters can be found easily using casting

ASC() and CHR() functions are used

E.g. CHR(77) converts ASCII number 77 to ASCII character M

E.g. ASC(b) converts ASCII character b to ASCII number 98

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

What would be the best data types to use in the following:

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

What are operators?

A

Special characters that perform certain functions

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

What are the arithmetic operators?

A
Addition
Subtraction
Multiplication
Division
Exponentiation
Quotient (DIV)
Remainder / modulus (MOD)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the exponentiation operator ^ do?

A

Raises a number to a power

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

What does the quotient (DIV) operator do?

A

Returns the whole number

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

What does the remainder / modulus (MOD) operator do?

A

Returns the remainder

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

What do operators work on?

A

Integers / real data values (or a combination of the two)

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

What mathematical rule do computers follow?

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

Using BODMAS, calculate the following:

2 + 8 * 2

(2 + 8) * 2

A

2 + 8 * 2 = 18

(2 + 8) * 2 = 20

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

List the computing operators, their typical operator, an example and the result

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

What is the assignment operator?

A

=

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

What does the assignment operator do?

Give some examples?

A

It is used to assign values to constants or variables, for example:

Total = 100
Goals = 3
Cost = Total * 5
n = n + 5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What positioning should occur when using the assignment operator?

A

The name of the constant should be on the left of the = and whatever is being assigned should be on the right, for example

Dog’s name = Rio

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

What does a comparison operator do?

A

Compares the expression on the left hand side to the expression on the right

A Boolean value (True / False) is produced

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

What are the common comparison operators?

A
==
<> or !=
<
><=
>=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

List the common comparison operators, what they mean and examples if they are True or False

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

What is the difference between age = 25 and age == 25?

A

age = 25 versus is age 25

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

What are the two ways data values can be stored?

A

Constants or variables

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

What is the name of a constant or variable linked to?

A

The name of a constant or variable is linked to a memory location that stores the data value

*The size of the memory location depends on the data type

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

How are constants assigned?

A

Using the const command

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

What will happen if a constant value is manually changed

A

It will result in an error

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

When is a constant assigned a data value?

A

At the time of design

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

What is the benefit of a variable over a constant?

A

Variables can change their value

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

How do languages know the data type?

A

Some languages (e.g. OCR Exam Reference Language) assume the data type when it is assigned (e.g. pressure = 30) for the integer

Other languages need it to be declared (e.g. int pressure = 30) for the integer

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

What naming conventions exist for constants and variables?

A

Lower case for the first letter followed by a mixture of letters, numbers and underscores

Variable names must not contain spaces or start with a number

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

Write a program to calculate the number of points an athlete has (5x points for 1st, 2x points for 2nd and 0 points for anything else)

A

firsts = 0
seconds = 0
points = 0
firsts = input(“Enter the number of 1st places”)
seconds = input(“Enter the number of 2nd places”)
points = (5 * firsts) + (2 * seconds)
print(points)

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

What are the benefits of assigning constants?

A

The constants remain constant(!) so don’t need to be changed when the program runs

If they do change, at design level, they only need to be updated in one location

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

What are strings made up of?

A

Characters – alphanumeric (letters, numbers, spaces, symbols etc…)

Ad1@£moT _R87

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

How are strings written?

Give an example

A

In “double” or sometimes ‘single’ quotation marks

string1 = “Print me, I’m a string”
print(string1)

Print me, I’m a string

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

How can strings be joined together, and what is this known as?

Give an example

A

Strings can be combined by concatenation, often with the + operator

string1 = “My favourite food is”
string2 = “cheese”
print(string1 + “ “ + string2)

My favourite food is cheese

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

What is the position of the first character in a string usually numbered as?

A

0

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

What special function exist in manipulation (known as methods)?

A
upper
lower
length
left
right
subString
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

How are methods used?

Give an example

A

Methods act on a particular object (object name followed by a dot “.” and the method’s name), for example:

string1. upper()
string2. lower()
string3. length

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

List some typical functions (methods), what they do and how they would effect the string x which contains “Hello”

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

Show some Python specific methods

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

Write a method to get the first three letters of the variable name and have them manipulated into uppercase

A

name.left(3).upper

Python:

name[:3].upper()

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

Write a method to get the last two letters of the variable name and have them manipulated into lowercase

A

name.left(2).lower

Python:

name[-2:].lower()

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

The following code does not read correctly – what needs to be added to it?

name = David
surname = Boatswain

print(name + surname)

A

A space (“ “) needs to be added as it currently shows DavidBoatswain

name = David
surname = Boatswain

print(name + “ “ + surname)

David Boatswain

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

Write a method to get the first and last letters of the variable club

A

newclub = club.left(1) + club.right(1)

Python:

newclub = club[:1] + club[-1:]

print(newclub)

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

What is program flow and what are the two types of selection statement?

A

The order that steps are carried out – IF and SWITCH selection statements allow for program flow

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

What structure do IF statements usually have?

A

IF-THEN-ELSE

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

What do IF statements allow you to check for?

A

If a condition is True or False – carry out different actions depending on the outcome

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

Draw an IF statement flow diagram to check if the password entered is correct

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

Write a piece of pseudocode for granting access depending on the password entered

A

password = input(“Enter your password”)

if password == storedpassword then:
     print(“Access granted”)
else:
     print(“Access denied”)
end if
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What is a NESTED IF statement?

A

More complex IF statements – IF within another IF

NESTED IF statements check more than one condition, once the previous condition has been established (True or False)

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

Write a piece of pseudocode for granting access depending on the password and the Year Group being 11

A
password = input(“Enter your password”)
if user == Year11 then:
     if password == storedpassword then:
          print(“Access granted”)
     else:
          print(“Access denied”)
     end if
else:
     print(“User not in Year 11 – access denied”)
end if
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

What are ELSE IF statements (Python: elif)?

A

ELSE IF statements can check multiple conditions

They only check more conditions is the previous one was False

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

Write a piece of pseudocode for granting access depending on the password and the Year Group being 11 (with functions for Year 10 and Year 9 also included via ELSE IF statements)

A
password = input(“Enter your password”)
if user == Year11 then:
     if password == storedpassword then:
          print(“Access granted”)
     else:
          print(“Access denied”)
     end if
elseif user == Year10 then:
     print(“User not in correct year to access”)
elseif user == Year9 then:
     print(“User not in correct year to access”)
else:
     print(“Access denied”)
end if
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

What is a SWITCH statement (also known as a CASE statement)?

A

SWITCH (CASE) statements check the value of a variable (rather than checking if the statement is True or False)

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

When are SWITCH statements used?

A

SWITCH statements are used when you want a program to perform different actions for different values of the same variable

66
Q

Draw a SWITCH statement flow diagram for counting the votes in an election

A
67
Q

Write out the pseudocode for 3x candidates and count the votes cast for them

A
davidvote = 0
jessicavote = 0
rachelvote = 0
vote = input(“Please vote for your favourite person”)
switch vote:
     case “David”:
          davidvote = davidvote + 1
     case “Jessica”:
          jessicavote = jessicavote + 1
     case ”Rachel”:
          rachelvote = rachelvote + 1
     default:
          print(“Error with your vote, please try again”)
endswitch
68
Q

How does a SWITCH statement start and end?

A

Start with SWITCH parameter, e.g. switchvote

End with endswitch

69
Q

What is the advantage of a SWITCH statement?

A

They are a neater way to test different values of a variable (so are easier to maintain)

70
Q

What is the disadvantage of a SWITCH statement?

A

SWITCH statements can only check the value of one variable (unlike IF-ELSEIF statements which can check if multiple conditions are True

71
Q

What is iteration?

A

A programming construct – allowing a program to repeat certain steps until told otherwise or until a condition has been met

Often referred to as looping

72
Q

What are the benefits of iteration (looping)?

A

They greatly simplify a program

73
Q

Using iteration (looping), simplify this code:

A

Run a loop six times

74
Q

What are FOR loops?

Give an example of one

A

FOR loops are examples of count-controlled loops, repeating the code inside them a fixed number of times, for example:

for i = 1 to 10
print(“something”)
next i

75
Q

What is a WHILE loop?

A

WHILE loops are controlled by a condition at the start of the loop

They keep going while the condition is True

76
Q

Give an example of a WHILE loop

A
total = 0
target = input(“How much money do you want to save?”)

while total < target
funds = input(“How much money do you have?”)
total = total + funds
endwhile

77
Q

What are DO UNTIL loops?

A

DO UNTIL loops are controlled by a condition at the end of the loop

They keep looping until the condition is True

78
Q

Give an example of a DO UNTIL loop

A
total = 0
target = input(“How much money do you want to save?”)

do:
funds = input(“How much money do you have?”)
total = total + funds
until total >= target

79
Q

What does the following show?

A
80
Q

What are the Boolean data type values?

A

True or False

81
Q

How do electronic circuits make decisions?

A

Logic gates – two or more inputs are considered and outputs from the circuit are determined

82
Q

What do logic gates allow for and what states are they found in?

A

Logic gates allow an electronic system to make a decision based on a number of input

Inputs and outputs can be True (1 or ‘on’) or False (0 or ‘off’)

83
Q

What are the common Boolean operators?

A

AND
OR
NOT

*and XOR

84
Q

What are truth tables?

A

Truth tables show the logic gate calculations (showing all possible input combinations of 1s and 0s and the corresponding output)

85
Q

What does the following show?

A

AND gate

86
Q

What does the following show?

A

OR gate

87
Q

What does the following show?

A

XOR gate

88
Q

What does the following show?

A

NOT gate

89
Q

What is the truth table for the following AND gate?

A

Q = A AND B

90
Q

What is the truth table for the following OR gate?

A

Q = A OR B

91
Q

What is the truth table for the following XOR gate?

A

Q = A XOR B

92
Q

What is the truth table for the following NOT gate?

A

Q = NOT A

93
Q

What is needed for an AND gate to output a 1?

A

An AND gate can be used on a gate with two inputs. AND tells us that both inputs have to be 1 in order for the output to be 1

94
Q

What is needed for an OR gate to output a 1?

A

The OR gate has two inputs. One or both inputs must be 1 to output 1, otherwise it outputs 0

95
Q

What is needed for a XOR gate to output a 1?

A

The exclusive OR gate works the same as an OR gate, but will output 1 only if one or the other (not both) inputs are 1

96
Q

What is needed for a NOT gate to output a 1?

A

A NOT gate has just one input. The output of the circuit will be the opposite of the input. If 0 is input, then the output is 1. If 1 is input, then 0 is output

97
Q

What are complex logic gates?

A

Chains of logic decisions

98
Q

How many inputs does the following complex logic gate show and what order does it need to be completed in?

A

3 inputs (eight possible outcomes)

First find D

Second find E

Finally find Z

99
Q

Complete the truth table for the complex logic gate:

A

Z = D OR E or Z = NOT A OR (B AND C)

100
Q

What order is followed when combining Boolean operators?

A

Brackets

NOT

AND

OR

101
Q

Give an example of the Boolean operator AND, OR and NOT for an example that is True and and example that is False

A
102
Q

How are the Boolean operators AND, OR and NOT sometimes written in programming languages?

A

AND sometimes written as &&

OR sometimes written as ||

NOT sometimes written as !

103
Q

Write a Boolean containing code to keep score for Mike and Stu who are playing a best of 10 game match (ends when one wins 6 games, or they both win 5)

A
stu = 0
mike = 0
do:
     roundwinner = input(“Enter winner’s name”)
     switch roundwinner:
          case “Stu”:
               stunew = stunew + 1
          case “Mike”:
               mikenew = mikenew + 1
     endswitch
until stunew == 6 OR mikenew == 6 OR (stunew == 5 AND mikenew == 5)
104
Q

Write a Boolean containing code to keep a player alive (they die if any variable = 0, two are less than 20 or all are less than 40). Variables are food, water and bravery

A

if food == 0 OR water == 0 OR bravery == ) then:
alive = false
elseif (food < 20 AND water < 20) OR (food < 20 AND bravery < 20) OR (water < 20 AND bravery < 20) then:
alive = false
elseif food < 40 AND water < 40 AND bravery < 40 then:
alive = false
else:
alive = true
endif

105
Q

How can random number generation be useful in coding?

A

When you don’t want a program to follow the same path each time

They can be used to simulate random real-life events, e.g. rolling a dice, playing the lottery, flipping a coin etc…

106
Q

What code is used to generate a random number (in the OCR Exam Reference Language)?

A

random(x, y)

x and y can be integers or real numbers

107
Q

Write some code to simulate a dice roll

A

roll = random(1, 6)

print(roll)

108
Q

Write some code to simulate a dice roll that is performed three times

A

for i = 1 to 3
roll = random(1, 6)
print(roll)
next i

109
Q

Write a random selection to generate another random event, i.e. if a coin flip is heads or tails

A
number = random(0, 1)
if number == 0 then:
     print(“heads”)
elseif number == 1 then:
     print(“tails”)
endif
110
Q

How can a random number help with an array?

A

The random number generated can pick an element in the position of the array

number = random(0, 4)
chosenfruit = fruit[number]
Print(“today you should eat a “ + chosenfruit)

111
Q

Write a piece of code in Python for a lottery code generator (6x numbers between 1 and 49 and ideally put back repeats / sort before the print numerically)

A
112
Q

What is a more efficient way of storing data (e.g. 10x scores) than declaring 10x variables, e.g. score1, score2, score3 etc…?

A

Using an array (similar to a list (1D) or table (2D) which are much more efficient

113
Q

What is an array?

A

A data structure that holds similar related data (consisting of elements)

Each element has a position in the array and can hold a value (the data in an array must be the same type)

114
Q

How can an array be declared so it can be used?

Give an example for a score holding array

A

The array must be given an identifier and a size (the number of elements it will hold)

For example, array scores[9] is an array called scores consisting of 10 elements

115
Q

How are values assigned to an element within an array?

Give an example

A

The array name, elements position and value are identified

For example:

array scores[0] = 100
array scores[1] = 98
array scores[2] = 88

116
Q

How are values retrieved from an array?

Give an example

A

The array and element’s position are referred to. For example in the following array:

print(scores[0]) would output 100
print(scores[1]) would output 98

117
Q

Give an example of a 1-dimensional array

A
118
Q

Give an example of a 2-dimensional array

A
119
Q

How is a 2-dimensional array declared?

Give an example

A

The row and the column are declared, for example array scores[1,9] would give two rows and ten columns

120
Q

How are values assigned and retrieved for a 2-dimensional array?

A

Assigned via array scores[0,1] = 98

Retrieved via print(scores[1,4]) which would give the value 111

121
Q

What happens to the data when a program finishes or is closed?

A

The data is lost (unless it is stored in a file for access later)

122
Q

What are the two modes of operation for a file?

A

Read from – file opened so data can be read from it

Write to – file opened so data can be written to it

123
Q

What is each item of data written to or from a file known as?

A

A record

124
Q

How is a file opened?

Give an example

A

To open a file, it must be referred to by its identifier, for example:

file = openRead(“scores.txt”)

This would open the file scores.txt and allow its contents to be read

125
Q

How is a file opened for writing to?

Give an example

A

To open a file, it must be referred to by its identifier, for example:

file = openWrite(“scores.txt”)

This would open the file scores.txt and allow it to have data written to it

126
Q

How is a file closed?

A

file.close()

127
Q

Data held in a record can be read into what?

A

A variable or an array

128
Q

Give an example code to open scores.txt and read into a variable score

A

file = openRead(“scores.txt”)

score = myFile.readLine()

file.close()

129
Q

Give an example code to open scores.txt and read into an array called scores

A

file = openWrite(“scores.txt”)

for x = 0 to 9

 scores[x]=myFile.readLine()

next x

file.close()

130
Q

What statement is used to check to see if the last record has already been read?

A

endOfFile()

131
Q

Give an example of a code to read each record in scores.txt, placing them in an array called scores and ceasing when the last record has been reached

A

file = openRead(“scores.txt”)

while NOT file.endOfFile()

 scores[x]=myFile.readLine()

 x = x + 1

endwhile

file.close()

132
Q

How is data written to a file?

Give an example

A

Data is written one line at a time via writeLine

file = openWrite(“scores.txt”)

for x = 0 to 9

 file.writeLine(scores[x])

next x

file.close()

133
Q

What is a record?

A

A type of data structure, similar to an array

Collections of data values are stored

134
Q

What is the advantage of a record over an array?

A

Records can store values with different data types, such as strings, integers and Booleans

135
Q

Within a record what is each item referred to and what are they given when created?

A

Each item in a record is called a field

Each field is given a data type and field name when created (fixed in length at creation)

136
Q

What are the advantages of records?

A

They keep related information in one place

137
Q

Write a piece of pseudocode creating a record structure called ‘recipes’ with some different data types assigned to some example fields (e.g. recipe number, name, score etc…)

A
138
Q

How would variables be assigned to a record (with a few fields)?

A
139
Q

If there are multiple variables with the same record structure how can they be collected?

A

In an array

140
Q

What is SQL?

A

Structured Query Language

Used to search tables (usually databases) for specific data

*Records and fields of a database table are the rows and columns

141
Q

In SQL what follows the SELECT and FROM keywords?

A

SELECT followed by the names of the field (columns) that are required

FROM followed by the name of the table(s) to be searched

142
Q

How would all the planet names be returned from this database?

A

SELECT planetName FROM planets

143
Q

How would all the planet names and the planet ratings be returned from this database?

A

SELECT planetName, planetRating FROM planets

144
Q

How would all of the information be returned from this database?

A

Using the wildcard *

145
Q

What keyword is used within SQL to filter? Give an example using the database below:

A

WHERE

SELECT * FROM planets WHERE planetGravity > = 50

This would return Giants Deep

146
Q

Give an example of a WHERE filter using a Boolean operator in the database below:

A

SELECT planetName FROM planets WHERE planetDistance <= 200 AND planetAtmosphere = “Hostile”

This would return Brittle Hollow and Ash Twin

147
Q

What are the two scopes for variables?

A

Local and Global

148
Q

How is a variable made as global?

A

Global scope is added using the keyword global()

They can be used anytime after their declaration

149
Q

What is the benefit of using local variables (in sub programs)?

A

They do not affect, nor are affected by anything outside of the sub program

Variables can have the same name in different sub programs

150
Q

What are the two types of subprogram?

A

Procedures

Functions

151
Q

What is a subprogram?

A

Subprograms are small programs that are written within a larger, main program.

The purpose of a subprogram is to perform a specific task. This task may need to be done more than once at various points in the main program.

152
Q

What are the benefits of subprograms?

A

Usually small in size

Can be saved separately as modules (and used again on other programs)

Repeatedly used at various points in main program (code only needs to be written once)

153
Q

What is a procedure?

A

A subprogram that performs a specific task

When complete, the subprogram ends and the main program continues where it left off

154
Q

How is a procedure created?

Give the syntax

A

procedure identifier (value to be passed)

 procedure code

endprocedure

155
Q

Write a procedure to clear the screen by printing x number of blank lines

A

procedure clear_screen(x)

 for i = 1 to x: 

 print(" ")

endprocedure

156
Q

How does a procedure run? What is needed for this to occur?

A

It is called

The procedure name is needed + any values that the procedure will need

157
Q

What is a function?

A

A function is a subprogram that performs a specific task

Unlike a procedure, a function manipulates data and returns a result back to the main program

158
Q

How is a function run?

A

It is called

159
Q

What is needed to call a function?

A

Function identified

Value to be passed into the function

Variable for the function to return a value into

160
Q

What does the following show?

function f_to_c(temperature_in_f)

 temperature_in_c= (temperature_in_f –32) * 5/9

 return temperature_in_c

endfunction

A

A function

*Fahrenheit into Celsius