Section 5: Programming Flashcards

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

What are the 5 main data types?

A

1) Integer
2) Real (or float)
3) Boolean
4) Character
5) String

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

What are the effects of Weakly-typed and Strongly-typed programming languages?

A

Weakly typed languages will try to convert data types to avoid errors, however this can lead to unpredictable results. Strongly typed languages won’t try to convert data types and so will produce more errors but more predictable results.

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

What is casting?

A

Languages have functions that let you manually convert between data types - this is known as casting.
(e.g. int( ), float( ), bool( ), str( ) commands.)

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

How can you find the ASCII number of a character or the character an ASCII number represents?

A

Using the ASC( ) or CHR( ) functions.

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

What 5 main string manipulation functions are there?

A

x.upper - changes all characters in string x to upper case
x.lower - changes all characters in string x to lower case
x.length - returns the number of characters in string x
x[i] - extracts the character in position i from string x
x.subString(a,b) - extracts a string starting position a with length b from string x

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

What is a switch-case statement?

A

They check if a variable has specific values, they’re used when you want a program to perform different actions for different values of the same variable.

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

What is an Array and when is it used?

A

An array is a data structure that can store a collection of data clues all under one name. They are most helpful when you have lots of related data that you want to store and it doesn’t make sense to use separate variables. Each piece of data on an array is called an element - each element can be accessed using its position (or index) in the array.

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

What is a Record and what makes it different to an array?

What features does a Record have?

A

A record is a type of data structure which means that it is used to store a collection of data values.
One of the things that makes records so useful is that, unlike arrays they can store values with different data types, such as strings, integers and Booleans.
Each item in a record is called a field, and each field is given a data type and a field name when the record is created.
Records are fixed in length, which means that you can’t add extra fields to them once they’ve been created.

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

What is a procedure?

A

Procedures are sets of instructions stored under one name - when you want your program to do the whole set of instructions you only need to call the name of the procedure.

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

What is a function?

A

Functions are procedures that return a value.

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

When are procedures and functions useful?

A

Procedures and functions are useful when you have sets of instructions that you need to repeat in different places within a program. They give your program more structure and readability whilst cutting down on the amount of code you actually need to write.

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

Whats the difference between Parameters and Arguments?

A

Parameters are special variables used to pass values into a sub program. For each parameter you can specify a name, data type and a default value.
Arguments are the actual values that the parameters take when the sub program is called.

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

Whats the difference between local variables and global variables?

A

Local variables can only be used within the structure they’re declared in - they have a local scope.
Global variables can be used any time after their declaration - they have a global scope.

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