02 Section 5 - Data types, operators,constants, variables and strings Flashcards

1
Q

What are the main five data types of programming languages?

A
Integer
Real (or float)
Boolean
Character
String
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the pseudocode for Integer data type?

A

INT

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

What is the pseudocode for Real data type?

A

REAL

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

What is the pseudocode for boolean data type?

A

BOOL

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

What is the pseudocode for character data type?

A

CHAR

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

What is the pseudocode for string data type?

A

STRING

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

What is the characteristics of the integer data type?

A

Whole numbers only

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

What is the characteristics of the real data type?

A

Numbers that have a decimal part

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

What is the characteristics of the boolean data type?

A

Can only take one of two values, usually TRUE or FALSE

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

What is the characteristics of the character data type?

A

A single letter, number, symbol

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

What is the characteristics of the string data type?

A

Used to represent text, it is a collection of characters

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

What are the features of the different types of data types?

A
  • different data types are allocated different amounts of memory
  • using correct data types make code more memory efficient, robust and predictable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are weakly typed programming languages?

A

Languages that will try to convert data types to avoid errors, however this can lead to unpredictable errors

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

What are strongly typed programming languages?

A

Languages that 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
15
Q

How much memory does an integer data type take up?

A

2/4 bytes

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

How much memory does a real data type take up?

A

4/8 bytes

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

How much memory does a boolean data type take up?

A

1 bit is needed but 1 byte is normally used

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

How much memory does a character data type take up?

A

1 byte

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

How much memory does a string data type take up?

A

1 byte for every character in the string

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

What is casting?

A

Changing the data type

-languages have functions that let yopu manually convert between data types

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

What commands can you use to convert between data types?

A

int()
float()
bool()
str()

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

What commands can you use top convert between ASCII numbers and characters?

A

ASC()

CHR()

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

What are arithmetic operators?

A

Arithmetic operators take two values and perform a maths function on them

24
Q

What are the different arithmetic operators?

A
addition
subtraction
multiplication
division
exponential 
quotient
remainder(modulus)
25
What is the exponential operator?
Used to raise a number to a power
26
What is the quotient operator?
Returns the whole number part of a division
27
What is the modulus operator?
Gives the remainder of a division
28
What is the typical operator for addition?
+
29
What is the typical operator for subtraction?
-
30
What is the typical operator for multiplication?
*
31
What is the typical operator for division?
/
32
What is the typical operator for exponentiation?
^ or **
33
What is the typical operator for quotient?
DIV
34
What is the typical operator for modulus?
MOD or %
35
What is the assignment operator?
= | used to assign values to constants or variables
36
What are comparison operators?
==, <>, !=, , <=, >= they compare the expression on their left hand side to the expression on their right hand side and produce a Boolean value (true or false)
37
What is the comparison operator to show something is equal to?
==
38
What is the comparison operator to show something is not equal to?
<> | !=
39
What can data values be stored as?
constants or variables
40
What does the name of a constant or variable link to?
a memory location that stores the data value | -the size of this memory location depends on the data type
41
What is a constant?
A constant is assigned a data value at design time that can't be changed
42
What happens if you try to change the value of a constant in a program?
the interpreter or compiler will return an error
43
What is a variable?
A memory location for data to be stored which can change its data value during the running of the program
44
When do constants and variables need to be declared?
at the start of a program
45
What are reasons for assigning values as constants?
- if they don't need to be changed during the running of a program - if the value was changed, you'd only need to change it at the declaration of the constant rather than throughout the code
46
How can you declare constants and variables?
``` Examples of declarations of constants: CONST name = data CONST name as DATA TYPE = data Examples of declarations of variables: VAR name as DATA TYPE = data DATA TYPE name = data ```
47
How are strings written?
Strings are usually written inside double quotation marks ", but some times single quotes are used '.
48
What is concatenation?
When strings are joined together to form new strings | -using the + operator
49
What are the character in a string numbered as?
The characters in a string are usually numbered starting at 0
50
What are examples of common string manipulation?
x.upper x.lower x.length x[i] x.subString[a, b]
51
What is the operation of the function x.upper?
changes all the characters in string x to upper case
52
What is the operation of the function x.lower?
changes all the characters in string x to lower case
53
What is the operation of the function x.length?
returns the number of characters in string x
54
What is the operation of the function x[i]?
extracts the character in position i from string x
55
What is the operation of the function x.subString[a, b]?
extracts a string starting at position a with length b from string x