Answers for "python random.random()"

87

python random

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
Posted by: Guest on December-23-2019
18

how to use random in python

import random
print(random.randint(3, 7)) #Prints a random number between 3 and 7
array = [cars, bananas, jet]
print(random.choice(array)) #Prints one of the values in the array at random
Posted by: Guest on March-07-2020
2

python random

import random

# random number 1 to 100
x = random.randrange(0, 99)
x = x + 1
print(x)
Posted by: Guest on September-15-2021
16

python random

#import random 
import random

names = ['Harry', 'John', 'Smith', 'Larry']

#print random name from names
print(random.choice(names))

#print random integer in a range of numbers
print(random.randint(1, 100)
Posted by: Guest on May-30-2020
7

python randint

from random import randint

print(randint(3, 9))
Posted by: Guest on January-16-2020
6

python random float

# The random function random() returns a random float between
# zero and one
import random
random.random()
Posted by: Guest on February-28-2020

Python Answers by Framework

Browse Popular Code Answers by Language