+ 2
Random function
anyone who knows what the python code of the random function would be? thnxx
3 Antworten
+ 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)
+ 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!!
+ 2
but how could i make my own random function, without importing libs?