Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are the different ways to generate random numbers?

Answer Posted / chaitanya

Random module is the standard module that is used to generate the random number.

The method is defined as:

import random

random.random()

The statement random.random() method return the floating point number that is in the range of [0, 1). The function generates the random float numbers. The methods that are used with the random class are the bound methods of the hidden instances. The instances of the Random can be done to show the multi-threading programs that creates different instance of individual threads. The other random generators that are used in this are:

• randrange(a, b): it chooses an integer and define the range in-between [a, b). It returns the elements by selecting it randomly from the range that is specified. It doesn’t build a range object.

• uniform(a, b): it chooses a floating point number that is defined in the range of [a,b).Iyt returns the floating point number

• normalvariate(mean, sdev): it is used for the normal distribution where the mu is a mean and the sdev is a sigma that is used for standard deviation.

• The Random class that is used and instantiated creates an independent multiple random number generators.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When does a dictionary is used instead of a list?

851


How to terminate a python subprocess launched with shell=true?

1001


Explain the use of try: except raise, and finally?

831


What do you understand by deque in python?

947


You are having multiple memcache servers running python, in which one of the memcacher server fails, and it has your data, will it ever try to get key data from that one failed server?

890


What is the best interpreter for python?

1060


What is __init__.py used for?

966


What is a 4 tuple?

1057


Are there maps in python?

869


What are the differences between pass and continue?

997


Can you sort a string in python?

910


Can I create a website with Python?

1052


Write a command to convert a string into an int in python.

986


Can we use break in if statement in python?

848


What are python methods?

867