Question 1
1 markWhich of these values could NOT be returned by random(-1.0,10.0)?
Choose your answer.
- -1.0
- 0.5
- 9.99
- 10.5
Model answer
10.5
Explanation
random(-1.0,10.0) gives a real number from -1.0 to 10.0, including both limits, so -1.0, 0.5 and 9.99 are all possible. 10.5 is larger than the upper limit. A common mistake is to think a negative value or the lower limit itself cannot be returned.
Mark scheme
-
1 mark
10.5
Only this option: it is above the upper limit of 10.0. -1.0 is the lower limit, which is included. If more than one option is given, 0 marks.