programming Flashcards

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

what is a variable

A

a memory location that is used to temporarily hold data value,
it can change while program is running

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

benefits of subprograms:

A

easier to maintain: code is shorter, easier to understand
avoids repetition of code: sub can be called instead of copying/pasting, quicker to develop new programs
work can be delegated between team members, reduces development time

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

count controlled loop to print out numbers 1 to 10 in ascending order

A

for i = 1 to 10
print i
next i

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

what is high level language:

A

aimed to be understood by humans, has to be translated before it can be run

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

Integrated Development Environment tools:

A

editor, to enable program code to be entered/ edited
translator, to enable code to be executed

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

three programming constructs:

A

selection
iteration
sequence

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

local variable advantages

A

saves memory - only uses memory when that local variable is needed - global variables use memory even if not used

easier to debug local variables as they can only be changed within one subroutine

you can reuse subroutines with local variables in other programs

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

global variable advantages

A

variables can be used anywhere in the whole program (and in multiple subroutines)

makes maintenance easier as they are only declared once

can be used for constants - values that remain the same

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

what is casting?

A

changing the data type of a variable to another data type

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

why is casting needed?

A

-to concatenate two strings, the ALU needs to use numbers to perform the arithmetic operation
-therefore string needs to be ‘cast’ to a number

-integers require less bits of memory than real. numbers

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

what is a boolean data type?

A

-true or false
-used to track if something has happened or happened or not

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

return a string length:

A

length = string.length

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

convert a string to all upper/lower case

A

ustring = string.upper
lstring = string.lower

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

extract the ‘mat’ letter from
string = “tomato”

A

chars = string.substring(2,3)

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

output PUT from someText = “Computer Science”

A

print ((someText.substring(3,3).upper)

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

generate a random number betw 1 and 6:

A

myNum = random(1,6)

17
Q

advantages of using subprograms

A
  • program is easier to write
  • program is easier to debug
  • creating reusable components
  • functions could be gathered together into a library for easy reuse across multiple programs
18
Q

difference between functions and procedures

A
  • functions return values and create reusable program components
  • procedures create modular structure to a program making it easier to read
19
Q

create a function called ‘greeting’ to concatenate a name with hello

A

procedure greeting(“name”)
print(“hello” + name)
endprocedure

20
Q

describe how a character set is used to represent the string value stored in a variable

A

-each character has unique binary value
-binary value of each character store/combined (in order)

21
Q

Use pseudocode to write an algorithm that does the following :
*Inputs the title and year of a book from the user.
*Uses the librarycode function above to work out the book code.
*Permanently stores the new book code to the text file bookcodes.txt

A

title = input(“enter title”)
year = input (“enter year”)
code = librarycode(title, year)
myFile.writeLine(librarycode(title, year))
MyFile.close()