Skip to content

Utilities

Below is a list of all of some other helpful functions available within spark.

All of the examples below assume you have the boilerplate from the notebook setup in your code

Create a random float between 0 and 1

To generate a random float between 0 and 1 use:

1
random()

Example(s):

Printing a random value between 0-1

1
2
3
4
5
%%ignite

def setup():
    size(200, 200)
    print(random())

Results in:

random demo

Create a random int

To generate a random integer between 0 and n (inclusive) use:

1
randint(n)

Parameters

  • n: (int) The highest value in the range

Example(s):

Printing a random value between 0-10

1
2
3
4
5
%%ignite

def setup():
    size(200, 200)
    print(randint(10))

Results in:

random demo