Easy1 markMultiple Choice
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?
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
Q01.1Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to fo...EasyQ01.3What is the result of concatenating the contents of the variables `city` and `landmark` in Figure 1?EasyQ01.5The subroutine `POSITION` finds the first position of a character in a string.
For example, `POSI...EasyQ02.1Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-co...EasyQ02.2In the algorithm in Figure 2, what will be output when the user input is 10?Medium
Expert