Skip to main content

Posts

Showing posts with the label random

Diving Into Modules - Random Module

  Source:  Cyndie Meyer Random Module: This is an inbuilt module we get in the Python ecosystem and is used for bringing some variability in the program whenever required. This module is full of a ton of functions that are continuously in use in real life. Note! : To use the functions in this module, you have to import this module at least  once. The syntax for this operation is given below. Syntax: import random Some Functions in Random Module random():   This function returns a float value between 0 and 1. Syntax: x = random.random() print(x) randrange():   This function returns a random number between any given range (exclusive of the last number). Syntax: y = random.ranrange(2,7) print(y) randint():  This function returns a random number between any given range (inclusive of the last number). Syntax: z = random.randint(2,7) print(z) More functions will be continued in a later blog post... ©SGPython