0

Define

import random for i in range(5): value = random.randint(1, 6) print(value) #When did we define randit? Assuming that random is already defined by someone.

2nd May 2018, 1:08 AM
Medo Hamdani
Medo Hamdani - avatar
3 Answers
+ 3
The import system scans the module and sets up its properties (etc) into global/local vars (so that you can refer to them) import random # directory of props, methods, vars... print(dir(random)) # show the docstring print(random.randint.__doc__)
2nd May 2018, 6:14 AM
Kirk Schafer
Kirk Schafer - avatar
+ 5
Try this variation of import to see what's available after import: # globals() or locals() print(globals(), "\n") from random import * # more toys! print(globals(), "\n")
2nd May 2018, 6:30 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
It is defined in the random class object.
2nd May 2018, 1:47 AM
Adam
Adam - avatar