Is it possible to manipulate the numbers of a randint?

-1

For example, I wanted the numbers generated by a randint to be 350 , 400 , 450 and 500 . Would you be able to do that?

    
asked by anonymous 19.07.2018 / 21:54

2 answers

6

From what I understand, what you want to do is generate numbers within a range and set the step . In this case you can use random.randrange() , which receives the start, end, and step parameters. Something like:

import random
valor = random.randrange(350,501,50)

Please be clear on the following questions, this helps to help you:)

Reference: random documentation

    
19.07.2018 / 22:07
2

To do what you want, you could use random.sample , for example:

random.sample([350, 400, 450, 500], 1)

Where the first parameter is the possible values and the second parameter how many values do you want to return.

Will return:

  

[400]

Source: link

    
19.07.2018 / 22:07