This answer has an important error. If you want to produce a real number in the interval [x,y[, in general you use:
(randf() * (y-x)) + x.
From 1 to 10, you have
randf() * 9 + 1. This is because
randf() can be 1 as maximum. In this case, you would obtain 9 + 1 = 10. In the case proposed by this answer,
randf() * 11 + 1, if by chance
randf() turns out to be greater than 0.8 you get something greater than 10. So, there is a 20% chance of having a wrong answer.