Skip to content
Skip to main content

About this free course

Download this course

Share this free course

Data and processes in computing
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?



  • (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”].



  • (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}.



The set is {(h, m) ∈ Int × Int : 0 ≤ h and h m and m