QUESTION IMAGE
Question
complete the code to generate a pseudo - random integer between 1 and 50, including the point 50.
>> import secrets
>> secrets
Step1: Understand randint and randbelow
randint(a, b) generates a random integer N such that a <= N <= b. randbelow(n) generates a random integer in the range 0 to n - 1.
Step2: Analyze the requirements
We want a number between 1 and 50 inclusive. randbelow(51) will generate a number from 0 to 50, but we want from 1 to 50. randint(1, 50) would be correct if it were in the random module. In the secrets module, secrets.randbelow(50) generates a number from 0 to 49 and secrets.randint(1, 50) is the correct way to get a number in the range 1 - 50 inclusive.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
randint(1, 50)