# Randomly pick one variable

**URL:** <https://discourse.processing.org/t/randomly-pick-one-variable/21304>\
**Category:** Beginners\
**Created:** [May 26, 2020, 4:58am UTC](https://discourse.processing.org/t/randomly-pick-one-variable/21304 "2020-05-26T04:58:05Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 28, 2020, 10:14pm UTC](https://discourse.processing.org/t/randomly-pick-one-variable/21304/13 "2020-05-28T22:14:37Z")

</div>

> [@jeremydouglass](#):
>
> (int)random(2)

Try wrapping each one in println() to see what it does. Maybe wrapping that in a for loop to see it multiple times.

```auto
for (int i=0; i<10; i++) {
  println(
    (int)random(2)
  );
}

```

`random(x)` returns a random float in the range 0-x. `(int)` casts the float to an integer.

---

_[View the full topic](https://discourse.processing.org/t/randomly-pick-one-variable/21304)._
