Skip to main content

Posts

Showing posts from November, 2021

Diving into Modules - Math Module

 >Math Module - Overall explanation Source:  freepik Introduction Other than Python built-in functions, there are numerous functions which can be found in some packages which need to be imported when needed which are called modules .  Such a module in python is the math module. Python's standard library provides a module viz. math for math functions that work with all number types except complex numbers. The Math module in Python is enriched with plenty of functions. Note!: To use the math module one must import it first into the Python compiler one has been working with. The syntax to do so is given below: import math FUNCTIONS IN MATH MODULE ceil(): This function returns the closest just above integer when a value has been passed. Syntax: x = math.ceil(2.4) print(x) floor():  This function returns the closest just below integer when a value has been passed. Syntax: y = math.floor(2.4) print(y) fabs():  This function returns the absolute number in flo...

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