nextFloat

Common
JVM
JS
Native
1.0
open fun nextFloat(): Float
fun nextFloat(): Float

Gets the next random Float value uniformly distributed between 0 (inclusive) and 1 (exclusive).

import kotlin.math.sin
import kotlin.random.Random
import kotlin.test.assertTrue

fun main(args: Array<String>) {
//sampleStart
if (Random.nextFloat() <= 0.3) {
    println("There was 30% possibility of rainy weather today and it is raining.")
} else {
    println("There was 70% possibility of sunny weather today and the sun is shining.")
}
//sampleEnd
}