Out of random() and randint(), which function should we use to generate random numbers between 1 and 5. Justify.
We should use the randint() function to generate random numbers between 1 and 5. The random() function is not suitable for this task because it returns a random real number (float) in the range 0.0 to 1.0. As shown in Table 7.3, this function takes no arguments and produces values strictly between 0.0 and 1.0, such as 0.65333522. Since the required range is between 1 and 5, the random() function cannot produce the necessary numbers. Therefore, randint() is the correct function to use for generating numbers in the specified range.
Explanation
The provided context (Table 7.3) explicitly defines random() as a function that returns a floating-point number between 0.0 and 1.0. This range is insufficient for generating numbers between 1 and 5. Although the definition for randint() is not explicitly present in the retrieved chunks, the question presents it as the alternative option. A student would identify randint() as the correct choice by eliminating random() based on its defined output range in the text.