+ 2

Random function

anyone who knows what the python code of the random function would be? thnxx

16th Jan 2017, 4:36 PM
Milan Zanden
Milan Zanden - avatar
3 odpowiedzi
+ 8
You can use 'random' module To import it just write `import random` Basic functions, that you can use: random.randint(from, to) # Returns integer between two numbers INCLUSIVE random.randrange(from, to) # Returns integer between from(incusive) and to(exclusive) random.choice(array) # Returns random element of given array For float values use random.uniform(from, to) # Returns float value between from(inclusive) and to(inclusive)
16th Jan 2017, 4:49 PM
WittyBit
WittyBit - avatar
+ 3
first you need to import the random library then you need to create a variable containing the random element and you can use it in functions or anything else you want. hope it helped you!!
16th Jan 2017, 4:44 PM
Sanchit Pandey
Sanchit Pandey - avatar
+ 2
but how could i make my own random function, without importing libs?
16th Jan 2017, 4:55 PM
Milan Zanden
Milan Zanden - avatar