Identifiers and Operators
12 Grade 10 Computer Studies questions on Identifiers and Operators, with worked marking schemes. 12 questions are available on this topic in full.
Question 1
1 markA learner writes the expression 4 + 6 * 2 - 3 in a program. Following the normal order of operations, the value obtained is:
A. 20
B. 17
C. 11
D. 13
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 2
6 marksExplain the three categories of operators listed below and give one example of an operator in each category: arithmetic operators, relational operators, logical operators.
(6 marks)
Marking scheme
Award 1 mark for the explanation and 1 mark for a correct example in each category (maximum 6). 1. Arithmetic operators - used to carry out calculations on numeric values (1). Example: + , - , * , / , MOD or DIV (1). 2. Relational (comparison) operators - used to compare two values and give a result of True or False (1). Example: > , < , = , <> , >= or <= (1). 3. Logical operators - used to join or reverse conditions so that a single True or False value is obtained (1). Example: AND , OR or NOT (1). An example placed under the wrong category earns no mark.
Question 3
1 markA shop gives a discount if a customer spends more than KSh 5,000 or holds a loyalty card. For a customer with amountSpent = 3000 and hasLoyaltyCard = True, the condition (amountSpent > 5000) OR hasLoyaltyCard evaluates to:
A. False, because OR requires both conditions to be true
B. True, because both of the conditions are true
C. False, because amountSpent is not greater than 5000
D. True, because OR needs only one of the two conditions to be true
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 4
4 marksState four rules that a programmer must observe when naming an identifier.
(4 marks)
Marking scheme
Award 1 mark for each correct rule (maximum 4). 1. The name must begin with a letter (or an underscore), never with a digit. 2. The name must not contain spaces; words are joined or separated with an underscore. 3. Reserved words (keywords) of the language, such as PRINT or IF, must not be used as identifiers. 4. Only letters, digits and the underscore may be used - no special characters such as -, % or /. 5. Each identifier must be unique within its scope. 6. The name should be meaningful and of a length allowed by the language.
Question 5
1 markIn a shop program, the pseudocode statement reads: total is assigned the value of total plus price. The effect of executing this statement is to:
A. test whether total is equal to total plus price
B. store the sum of the current value of total and the value of price back in total
C. create two new variables named total and price
D. print on the screen the value of total added to price
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 6
1 markA program shares 47 tree seedlings equally among 6 class plots. The expression 47 MOD 6 evaluates to:
A. 7
B. 7.83
C. 6
D. 5
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 7
3 marksA school allows a learner to join the athletics team only if the learner is aged 14 years or above and below 18 years. State the condition the program should test, using relational and logical operators, and explain why the logical operator you have chosen is the correct one.
(3 marks)
Marking scheme for this question
Create a free account to see itQuestion 8
1 markA store program holds stockLevel = 30. What is the value of the condition NOT (stockLevel < 25), and why?
A. True, because stockLevel holds a positive number
B. False, because NOT may only be used together with AND or OR
C. True, because NOT reverses the result of stockLevel < 25, which is false
D. False, because stockLevel is greater than 25
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 9
4 marksDistinguish between a variable and a constant as used in programming, giving one example of each from a program that calculates VAT on goods sold in a shop.
(4 marks)
Marking scheme
Variable (2 marks): - A named storage location whose value may change while the program is running (1). - Example: sellingPrice, which takes a different value for every item sold (1). Constant (2 marks): - A named storage location whose value is fixed when written and cannot be changed while the program runs (1). - Example: VAT_RATE holding 0.16, which stays the same for every item (1). The key distinction (value changes / value fixed during execution) must be made; examples alone score a maximum of 2 marks.
Question 10
1 markWhich of the following is a valid identifier for a variable that stores the number of bags of maize harvested?
A. bags-of-maize
B. 2bags_maize
C. bagsOfMaize
D. bags maize
(1 mark)
Marking scheme for this question
Create a free account to see itQuestion 11
4 marksA program holds RAINFALL = 27 and DAYS = 4. State the value of each of the following expressions: (a) RAINFALL DIV DAYS (b) RAINFALL / DAYS (c) RAINFALL > DAYS * 7 (d) (RAINFALL + DAYS) * 2
(4 marks)
Marking scheme for this question
Create a free account to see itQuestion 12
2 marksExplain two reasons why a programmer should use a meaningful identifier such as totalFees rather than a name such as x.
(2 marks)
Marking scheme for this question
Create a free account to see it9 more marking schemes are on this page. A free account opens all of them, and lets you build your own paper on the topics you have actually taught, laid out in KNEC format with its full marking scheme.
Create a free account