+ 1

oh oh

I can't find the function, that outputs random number... How can I fill the array by the random numbers? negative and positive numbers.đŸ€•

18th Apr 2020, 7:30 PM
shiryaeva
shiryaeva - avatar
8 Answers
+ 2
Karlusha , I think you need random.randint(startelement, endelement). Before that import the random module.
18th Apr 2020, 7:46 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Use math.randint. I can't explain here how to use it. Its a common method. Google it
18th Apr 2020, 7:47 PM
Sajid
Sajid - avatar
+ 1
so the fact of the matter is that the boundaries of the range of values ​​are unknown đŸ€•
18th Apr 2020, 7:51 PM
shiryaeva
shiryaeva - avatar
+ 1
Karlusha - infinity to + infinity... I mean you may have some idea about range. Not exact but let's say may be somewhat from -999999 to +999999... Try something like that...
18th Apr 2020, 9:04 PM
Arushi Singhania
Arushi Singhania - avatar
0
the problem is that choosing a number from minus infinity to infinity....how this i can write
18th Apr 2020, 8:43 PM
shiryaeva
shiryaeva - avatar
0
Karlusha I think I found your solution here https://machinelearningmastery.com/how-to-generate-random-numbers-in-JUMP_LINK__&&__python__&&__JUMP_LINK/ but you need to use numpy. And also the thing your trying to do is useless unless your a expert and trying to master every bit of python.
18th Apr 2020, 9:09 PM
Sajid
Sajid - avatar
0
There is no specific value to infinity to use that in an expression so you can't. But you can use integer maxvalue or min values as boundaries.. Edit: Or you can sys.max min values that are allowed by system from sys module. Some people asked same in this link see that may help you.. https://stackoverflow.com/questions/35361811/how-to-generate-n-random-numbers-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3-between-0-to-infinity https://stackoverflow.com/questions/31064245/generate-a-random-floating-point-with-no-range-constraint-but-including-inf
18th Apr 2020, 9:10 PM
Jayakrishna 🇼🇳