Easy1 markMultiple Choice
ProgrammingGeneralstring manipulationpseudo-code

AQA GCSE · Question 01.2 · Programming

The variable x is assigned a value using the statement:
x ← LEN(state)

Using Figure 1, what is the value of x?

Answer options:

A.

1

B.

5

C.

10

D.

12

How to approach this question

1. Identify the variable `state` from Figure 1. 2. The value of `state` is the string "California". 3. The `LEN()` function calculates the length of a string, which means counting the number of characters. 4. Count the characters in "California". 5. C-a-l-i-f-o-r-n-i-a. There are 10 characters. 6. Therefore, the value assigned to `x` is 10.

Full Answer

C.10✓ Correct
The correct answer is C (10). The `LEN` function returns the number of characters in a string. The variable `state` holds the string "California", which has 10 characters.
The `LEN()` function is a standard function in many programming languages and pseudo-code that returns the length of a given string. The length is the total number of characters in the string, including letters, numbers, symbols, and spaces. In this case, the variable `state` contains the string "California". By counting each character (C, a, l, i, f, o, r, n, i, a), we find there are 10 characters in total.

Common mistakes

✗ Miscounting the characters in the string.\n✗ Confusing the `LEN` function with indexing, which starts at 0.

Practice the full AQA GCSE Computer Science Paper 1 Python

31 questions · hints · full answers · grading

More questions from this exam