Data and processes in computing

This free course is available to start right now. Review the full course description and key learning outcomes and create an account and enrol if you want a free statement of participation.

Free course

# Exercises on Section 1

## Exercise 1

• (a) How many characters are there in the string “This text.”?

• (b) Which of the following are integers: 3, 0, 98, 4, –22,, ‘7’, [56]?

• (c) How many integers are there in the sequence [11, 23, 4, 56, 32]?

### Solution

• (a) There are ten characters: four in each word, a space, and a full stop.

• (b) Each of 3, 0, 98, 4 and −22 is an integer. is not an integer because it is not a whole number. ‘7’ is a character, and is not an integer. [56] is a sequence containing one integer, but is not an integer.

• (c) There are five integers in the sequence.

## Exercise 2

Suppose that the variable till2 holds data in the form of a sequence of barcodes. When an item is read at the checkout, the state of till2 is changed by appending the barcode of the item to the end of the sequence giving the state of till2. Suppose that till2 currently has the state [50222, 50345], and that an item with barcode 50111 is read, and then an item with barcode 50456 is read. Write out the state of the variable till2 at each stage.

### Solution

In turn, the state takes the following values:

 [50222, 50345] (at the start). [50222, 50345, 50111] (after 50111 is read). [50222, 50345, 50111, 50456] (after 50456 is read).

## Exercise 3

With item prices as given in Table 1, what is the sequence of prices corresponding to the sequence of barcodes [33050, 33050, 77502, 53151, 77502]? What is the total price of the items given by this sequence?

### Solution

The sequence of prices (given as integer numbers of pence, as in Table 1) is: [299, 299, 89, 440, 89]. The total price (in pence) is 1216 (or £12.16).

M263_1

### 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 nearly 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, find out more about the types of qualifications we offer, including our entry level Access courses and Certificates.

Not ready for University study then browse over 900 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 prospectus