Data Types And Databases (Ch4) (M2) Flashcards

1
Q

When programming, what should variables be given?

A

Variables should be given appropriate data types

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

What are the advantages of using the correct data types for variables?

A

Using the correct data types makes code more memory-efficient, robust and predictable.

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

What are the 5 main types of variable?

A

The five main types are:

Integer
Real (or Float)
Boolean
Character
String

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

What is a character?

A

A character is a single character, such as a letter, number or punctuation symbol

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

What is a string?

A

A string is a sequence of characters, including letters, numbers and punctuation

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

What is an integer?

A

An integer is a whole number

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

What is a real?

A

A real is a decimal number

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

What is a boolean?

A

A boolean is an answer that only has two possible values

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

What data type are telephone numbers stored as? Why?

A

Telephone numbers are always stored as a string, not an integer because they may include other symbols like “+” for example.

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

How much memory does an integer take up?

A

An integer takes up 2 bytes or 4 bytes

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

How much memory does a real take up?

A

A real takes up 4 bytes or 8 bytes

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

How much memory does a boolean take up?

A

A boolean takes up 1 bit, but 1 byte is usually used

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

How much memory does a character take up?

A

A character takes up 1 byte

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

How much memory does a string take up?

A

A string takes up 1 byte for every character in the string

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

What is casting?

A

Casting is converting a variable from one data type to another.

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

Give two examples of functions that let you manually convert between data types?

A

Languages have functions that let you manually convert between data types:

This can be done using:
int()
real() (or float())
bool()
str()

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

What does int(“1”) do?

A

Int(“1”) converts the string “1” to the integer 1

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

What does real(1) do?

A

Real(1) converts the integer 1 to the real number 1.0

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

What does bool(1) do?

A

Bool(1) converts the integer 1 to the boolean value True

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

What does str(True) do?

A

Str(True) converts the boolean value True to the string “True”

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

Give five examples of common arithmetic operators

A

+

Arithmetic operators:

*
/

MOD
DIV

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

What does modulus/MOD mean?

A

Modulus is how many whole numbers are left over after a division, e.g 5 MOD 26 = 1.

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

What does integers division/DIV do?

A

Integers Division/Quotient is how many times the number on the right fits into the number on the left. e.g 7 DIV 2 = 3, 2 goes into 7, 3 times.
However you only mention the remainder in Modulus.

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

What is exponentation?

A

Exponentiation is when one number multiplies by itself, the amount of times this is done, depends on the number.

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

What is 9 MOD 2

A

9 MOD 2 = 1

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

What is 12 DIV 8?

A

12 DIV 8 = 1

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

Give five examples of comparison operators

A

Comparison operators:

==
<> or !=
<
>
<=
>=

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

What is the assignment/comparison operator “=” used for?

A

The assignment/comparison operator “=” is used to assign values to constants or variables.

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

What do comparison operators do?

A

Comparison operators compare the expression on their left-hand side to the expression on their right-hand side and produce a Boolean value (either true or false).

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

Using WHILE, how can you create an infinite loop?

A

To create an infinite loop, use: WHILE True

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

What are the three boolean operators?

A

Boolean operators:

NOT
AND
OR

32
Q

If you use AND, what needs to happen?

A

If you use AND, both things have to be true

33
Q

What is NOT equivalent to?

A

NOT is equivalent to False

For example:
while not end_of_file

This is the same as:
end_of_file = false

34
Q

What is assignment?

A

Assignment is giving a variable or constant a value

35
Q

What is casting?

A

Casting is converting a variable from one data type to another

36
Q

What is a variable?

A

A variable is a value that is stored in memory and can change as the program is running

37
Q

What is a constant?

A

A constant is a value that is stored in memory and does not change as the program is running

38
Q

What are the three programming constructs used to control the flow of a program?

A

There are three constructs of programming that are used to control the flow of a program:

Selection (Decision making using statements)
Sequence (Structuring code into a logical, sequential order)
Iteration (Repeating code using for or while loops)

39
Q

What are the two parts of a variable?

A

A variable has two parts: The data value and an identifier

40
Q

In an efficient program, how will variables be used?

A

In an efficient program:
Variables will have sensible names
Variables will have appropriate data types
The purpose of variables will be immediately stated in the program

41
Q

Why is using clear variable names important?

A

Using clear variable names is important because it will mean that other programmers will be able to work out the purpose of the code, without the need for extensive comments.

42
Q

Large programs are often modular. What does this mean?

A

Large programs are often modular, meaning they are split into subroutines with each subroutine having a dedicated purpose

43
Q

What is the difference between a local and global variable?

A

Local variables are declared within a specific subroutine and can only be used within that subroutine.

Global variables can be used at any point within the whole program.

44
Q

Give one advantage of a local variable

A

Local variable advantages:

Saves memory - it only uses memory when that local variable is needed - global variables use memory whether they are used or not.
Easier to debug local variables - because they can be changed within one subroutine.
You can reuse subroutines with local variables in other programs

45
Q

Give one advantage of a global variable

A

Global variable advantages:

Variables can be used anywhere in the whole programs (and in multiple subroutines).
It makes maintenance easier as they are only declared once.
They can be used for constants - values that remain the same.

46
Q

Give one advantage of a constant

A

Advantages of constants:

Make a program easier to read, as it is declared and assigned at the top of a program
Can be easily changed in one place, instead of it changing a value throughout a program

47
Q

What is the code to find the length of a string, in pseudocode and visual basic?

A

In pseudocode, it is written:
stringName.length

In VB it is written:
stringName.length()

48
Q

What is a substring?

A

A substring is a smaller part of a string

49
Q

What is concatenation?

A

Concatenation is the proceess of joining two or more strings together

50
Q

What is an array?

A

An array is a static data structure that can hold a fixed number of data elements.

51
Q

What is always the index of the first number of an array?

A

The first number in an array always has an index of 0

52
Q

What is the index?

A

The index is a number that indicates an element’s position in the array

53
Q

To traverse an array, what can be used to display each data element in order?

A

To traverse an array, a for loop can be used to display each data element in order

54
Q

Because the size of an array is fixed, what two things can you not do?

A

Because the size of an array is fixed, you can’t:
Insert new values
Delete values

55
Q

Declare an array called cars, that stores 8 items

A

Array cars[8]

56
Q

How can two dimensional arrays be represented?

A

Two dimensional arrays can be represented by a table

57
Q

What must all the data in a two dimensional array have in common?

A

All the data in a two dimensional array must be the same data type

58
Q

What do you need to use, to search for a specific value in a 2D array?

A

To search for a specific value in a 2D array, you need two for loops. One for the row and another for the values of each row.

59
Q

What is the difference between an array and a database?

A

An array can only store one data type. Whereas, databases can store multiple data types.

60
Q

What is a database?

A

A database is a table, or a collection of tables that store data.

61
Q

What is the software that operates on data in a database called?

A

The software that operates on data in a database is called a database management system. (DBMS)

62
Q

What is a table?

A

A table is a collection of data that relates to an entity

63
Q

What is a record?

A

A record is a collection of data about a single entity

64
Q

What is a field?

A

A field is a unique piece of data about an entity

65
Q

What is a field name?

A

A field name is an identifier for the single piece of data

66
Q

What is a query?

A

A query is where we search for data in a database.

67
Q

What language is used to create, update, delete, and query a program’s database?

A

SQL (Structured Query Language) is used to create, update, delete, and query a program’s database

68
Q

What does Create Table do?

A

Create Table creates a database table

69
Q

What does Select do?

A

Select selects data in a database table

70
Q

What does Update do?

A

Update changes data in a database table

71
Q

What does Delete do?

A

Delete removes data from a database table

72
Q

What does Insert Info do?

A

Insert Info inserts data into a database table

73
Q

What is each record made up of?

A

Each record is made up of information about a person or thing

74
Q

Records should have a key field. What is a key field?

A

A key field is unique data that identifies each record

75
Q

Why are records useful?

A

Records are useful becasuse they can store values with different data types