2.2-2.3 Flashcards

1
Q

What is an integer

A

Whole number
Int

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

What is a real/float

A

Numbers with decimals
real

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

What is a Boolean

A

Can take one of two values(true/false)
bool

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

What is a character

A

Single letter,number or symbol
char

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

What is a string

A

Text
string

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

What do strings and characters always need when coding

A

Speech marks

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

Advantages of data types

A

Make code more memory efficient, robust and predictable

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

What is casting and give an example of coding

A

Converting between data types
real(1) converts integer to real 1.0

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

What do arithmetic operators do, what data types do they work on and give an example

A

Take two values and perform maths functions on them
Work on real or integer values
DIV and MOD

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

What is DIV

A

Returns while number of the division

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

What is MOD

A

Returns remainder of the division

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

What do assignment operators do and give an example

A

Assign values to constants or variables

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

What are comparison operators and give an example

A

Compare value from left to right side to produce a Boolean value(true/false)

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

What is a constant

A

Assigned the data value at design time and can’t be changed while running

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

What is a variable

A

Can change values

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

What is concatenation

A

Joining two strings together to form a new string using the + operator

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

Code to put all character to upper or lower case

A

X.upper
X.lower

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

Code to get the number of characters in a string

A

X.length

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

Code to extract the first I characters from a string or last I characters

A

X.left(I)
X.right(I)

20
Q

Code to extract a string starting at a with length b

A

X.substring(a,b)

21
Q

Code to get a random number

A

X = random(1,6)

22
Q

What is a one dimensional array and give code

A

List
Family = [“jess”, “Alice”]

23
Q

What is a two dimensional array

24
Q

How to open a file

A

File = open(“file.txt”)

25
How to close a file
File.close()
26
How to read a file line
File.readline()
27
How to write a line to a file
File.writeline(“hello”)
28
How to end a file
EndOfFile()
29
How to create a new file
NewFile(“myFile.txt)
30
What is a record
Stores à collection of data values with different data types
31
What is each item in a record called
A field
32
How to make a record with examples
1) create record Record recipes Int recipe number String recipe name End record 2)assign to variables Recipe1 = recipes(1,”chocolate cake”) 3)use variable name to access Print(recipe1) Print(recipe1.recipename)
33
What is a procedure
Set of instructions stored under one name and when you want to repeat you only have to call the name
34
What is a function
A set of instructions stored under one name and when you want to repeat you only have to call the name but they always return a value
35
Why are functions and procedures useful
Cut down on the amount of code written as only need to call it Results in less errors Easier to debug Easier to read code
36
What is a parameter
Special variables used to pass values into a sub program
37
What is an argument
Actual values that parameters take when sub values are called
38
Do procedures have parameters
Sometimes but not always
39
Procedure in code
Procedure welcome() Print(“hello”) End procedure
40
Does a function need a parameter
Yes at least one
41
Why is a function always assigned to a variable
Otherwise the value will be lost
42
Function code
Function joinstrings(x,y) Return x + “ “ + y End function Subject = joinstrings(“computer”,”science”) Print(subject)
43
What is a variable scope
Which parts of the program the variable can be used in
44
What is a local variable and the advantages
Used within the structure they’re declared in (sub program) Can’t affect anything outside and can use the same variable name again outside
45
What is a global variable and the advantages
A variable anytime after their declaration Used anywhere but value in large program is hard to keep track of