Data and processes in computing

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

# Exercises on Section 2

## Exercise 4

Let A be the set of integers between 100 and 999 inclusive.

• (a) Express A in the form A = {x ∈ ?? : condition}

• (b) What is the cardinality of A?

### Solution

• (a) A = {xInt : 100 ≤ x and x ≤ 999}. (There are other correct solutions.)

• (b) There are 999 integers between 1 and 999 inclusive. The set A does not contain the integers between 1 and 99 inclusive, and there are 99 of these. So A has cardinality 999 − 99 = 900.

## Exercise 5

If B = {sSeqOfChar : s starts with ‘T’ and s has length 4}, which of the following is a member of the set B?

• (a) “This”.

• (b) [‘T’, ‘h’, ‘i’, ‘s’, ‘.’].

• (c) [“T”, “h”, “i”, “s”].

### Solution

• (a) “This” is in B. It is a string (a sequence of characters), it contains four characters (so has length 4), and it starts with the character ‘T’.

• (b) [‘T’, ‘h’, ‘i’, ‘s’, ‘.’] is not in B. It is a string starting with ‘T’, but it contains five characters (has length 5). (Do not forget to count the character ‘.’.)

• (c) [“T”, “h”, “i”, “s”] is not in B. Each member of this sequence is a string, not a character. (Note that “T”, etc, are enclosed in double inverted commas.)

## Exercise 6

Suppose that each possible time of the day is stored as a pair of integers, where the first integer gives the hour and the second integer gives the minute. For example, (14, 45) represents a quarter to three in the afternoon. (Midnight is (0, 0) rather than (24, 00).) Express the set of possible times of the day in the form {(h, m) ∈ ?? : condition}.

### Solution

The set is {(h, m) ∈ Int × Int : 0 ≤ h and h < 24 and 0 ≤ m and m < 60}.

## Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371