15 - Data Types Flashcards

(26 cards)

1
Q

why are data types important?

A

so that your code knows what kind of information it’s handling

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

why have data types (3)

A
  1. better error detection
  2. better modularization
  3. better documentation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

categories of data type (3)

A
  1. primitive data types
  2. character string types
  3. array types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

primitive data types (3)

A
  1. numeric types
  2. boolean types
  3. character type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

data types that represent numbers (4)

A
  1. integer
  2. floating-point
  3. complex
  4. decimal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

on numeric types:

represent mathematical integers; whole numbers

A

integer

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

on numeric types:

represent real numbers with decimals

A

float

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

on numeric types:

used for double-precision values

A

double

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

on numeric types:

represent numbers with real and imaginary parts

A

complex

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

on numeric types:

represents exact decimal representation

A

decimal

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

boolean has only two values: __ or __

A

true, false

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

represents a single character, stored as numeric codes (ASCII, Unicode)

A

character type

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

design considerations of character string types (3)

A
  1. implementation
  2. string length
  3. operations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what kind of character string type implementation is show below:

subj = “CMSC 124”

A

primitive (built-in) type

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

what kind of character string type implementation is show below:

char str[8];
strcpy(str, “CMSC 124”);

A

array of char

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

on string length:

string length is fixed once declare

A

static length

17
Q

on string length:

string length can vary but with a limit

A

limited dynamic

18
Q

on string length:

string length may change without any limitations

A

dynamic length strings

19
Q

dynamic length strings, despite being flexible, must also consider the __

A

additional overhead

20
Q

string operations (5)

A
  1. assignment
  2. concatenation
  3. substring
  4. lexical comparison
  5. patter matching
21
Q

what string operation is shown below:

“abc” < “bcd” → True

A

lexical comparison

22
Q

what string operation is shown below:

Regex r”^[A-Z]{3}\d{3}$”

A

pattern matching

23
Q

a homogeneous collection of data in which each element is identified by its position in the collection

24
Q

__ are usually accessed using the array identifier and an index or subscript

A

array elements

25
true or false: array indexing may use zero indexing or let the user choose
true
26
illustrates different approaches to memory representation and length management
strings and arrays