Posts From Python Modules

Python fractions Module

Python fractions module enables the user to manage fractions related computations in an efficient manner. This module enables us to create fractions from integers, floats, decimal, and strings. This fraction module supports rational number arithmetic operations. Basics of fractions module 1. Importing a fraction module: 2. Instantiate the fraction class: There are a number of […]

Python math Module

Python math module helps the user to get direct access to the mathematical functions in their program. Thus, it helps to solve and minimize complex computations. In order to avail the functionalities of the math module, we need to import it in our code using import math statement. The math module does not support Complex […]

Python argparse Module – Parse Command-line Arguments Easily

When writing command-line scripts in Python, we might have come across a situation wherein we would need to add more command-line options for our program. Doing the argument parsing by ourselves tend to be very tedious and time-consuming, and often slow us down a lot. Python’s argparse module provides a solution to this problem. The […]

Python random Module – Generate Random Numbers/Sequences

This article is about the random module in Python, which is used to generate pseudo-random numbers for various probabilistic distributions. Python random Module Methods 1. seed() This initializes a random number generator. To generate a new random sequence, a seed must be set depending on the current system time. random.seed() sets the seed for random […]

HTMLParser in Python 3.x

html.parser.HTMLParser provides a very simple and efficient way for coders to read through HTML code. This library comes pre-installed in the stdlib. This simplifies our interfacing with the HTMLParser library as we do not need to install additional packages from the Python Package Index (PyPI) for the same task. What is HTMLParser? Essentially, HTMLParser lets […]

Creating a Python Module

So, you’ve been learning Python for quite a while now. As a beginner, it is common practice to have a one-file program that has all the code organized with the use of classes and functions. But as you get more advanced, and your code gets more complex, you need to learn to use multiple files. […]