Generate random numbers in python?

Submitted 6 months, 2 weeks ago
Ticket #372
Views 95
Language Python
Priority Medium
Status Closed

Is there any way to generate random numbers in python?

If there is a way ,what is it?

How many are there to generate?

Thanks in advance.......

Submitted on Mar 10, 21
add a comment

2 Answers

Verified

You can use randint method.

Eg., import random #import random module

variable = random.randint(give the range here)

print(variable)

Hope this works

Submitted 6 months, 2 weeks ago


Verified

This is what Jaanvi is saying:

import random

# set a range ---
# I've set a range between 0 and 100
# since last value is exclusive
rand_value = random.randint(0, 101)

print(rand_value)

You can find more about random here: python docs - random (https://docs.python.org/3/library/random.html)

Submitted 6 months, 2 weeks ago


Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message