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

You may prefer our related Brainscape-certified 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
Q

What is the exponential operator?

A

Used to raise a number to a power

26
Q

What is the quotient operator?

A

Returns the whole number part of a division

27
Q

What is the modulus operator?

A

Gives the remainder of a division

28
Q

What is the typical operator for addition?

A

+

29
Q

What is the typical operator for subtraction?

A

-

30
Q

What is the typical operator for multiplication?

A

*

31
Q

What is the typical operator for division?

A

/

32
Q

What is the typical operator for exponentiation?

A

^ or **

33
Q

What is the typical operator for quotient?

A

DIV

34
Q

What is the typical operator for modulus?

A

MOD or %

35
Q

What is the assignment operator?

A

=

used to assign values to constants or variables

36
Q

What are comparison operators?

A

==, <>, !=, , <=, >=
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
Q

What is the comparison operator to show something is equal to?

A

==

38
Q

What is the comparison operator to show something is not equal to?

A

<>

!=

39
Q

What can data values be stored as?

A

constants or variables

40
Q

What does the name of a constant or variable link to?

A

a memory location that stores the data value

-the size of this memory location depends on the data type

41
Q

What is a constant?

A

A constant is assigned a data value at design time that can’t be changed

42
Q

What happens if you try to change the value of a constant in a program?

A

the interpreter or compiler will return an error

43
Q

What is a variable?

A

A memory location for data to be stored which can change its data value during the running of the program

44
Q

When do constants and variables need to be declared?

A

at the start of a program

45
Q

What are reasons for assigning values as constants?

A
  • 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
Q

How can you declare constants and variables?

A
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
Q

How are strings written?

A

Strings are usually written inside double quotation marks “, but some times single quotes are used ‘.

48
Q

What is concatenation?

A

When strings are joined together to form new strings

-using the + operator

49
Q

What are the character in a string numbered as?

A

The characters in a string are usually numbered starting at 0

50
Q

What are examples of common string manipulation?

A

x.upper
x.lower
x.length
x[i]
x.subString[a, b]

51
Q

What is the operation of the function x.upper?

A

changes all the characters in string x to upper case

52
Q

What is the operation of the function x.lower?

A

changes all the characters in string x to lower case

53
Q

What is the operation of the function x.length?

A

returns the number of characters in string x

54
Q

What is the operation of the function x[i]?

A

extracts the character in position i from string x

55
Q

What is the operation of the function x.subString[a, b]?

A

extracts a string starting at position a with length b from string x