Adeeba Khan

Adeeba Khan

20 Articles Published

Articles by Adeeba Khan

20 articles

Parse a website with regex and urllib in Python

Adeeba Khan
Adeeba Khan
Updated on 02-Apr-2026 538 Views

Web scraping is a powerful technique for extracting data from websites, enabling automated data collection and analysis. Python provides several tools to make web scraping tasks easier through its robust ecosystem of libraries. Two commonly used libraries for web scraping are urllib and re (regular expressions). The urllib module enables fetching web content, processing URLs, and sending HTTP requests. It provides a straightforward way to interact with web servers and retrieve HTML from web pages. The re module supports regular expressions, which are character sequences used to create search patterns for extracting specific data. In this article, we'll ...

Read More

Pattern Generation using Python time() module

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 398 Views

Pattern generation is a fundamental programming concept that involves creating ordered sequences or structures. Python's time module provides tools for working with time-related operations and can be creatively used to generate dynamic patterns that change over time. This article explores two approaches for creating patterns using Python's time() function: using time as a random seed for pattern generation and creating patterns directly based on current time components. Method 1: Using Time as Random Seed This approach uses the current time as a seed for the random number generator to ensure unique patterns are generated each time. Random ...

Read More

Python - Number Theoretic Transformation

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 1K+ Views

The Number Theoretic Transformation (NTT) is a mathematical technique used for efficient polynomial multiplication and convolution operations. It's closely related to the Fast Fourier Transform (FFT) but operates in finite fields, making it particularly useful in cryptography, error-correcting codes, and number theory applications. In this article, we'll explore two implementations of NTT using the Cooley-Tukey algorithm: one using complex numbers (traditional FFT) and another using modular arithmetic with integers. Method 1: Using Complex Numbers (Traditional FFT) The Cooley-Tukey FFT algorithm can be adapted for NTT by working with complex exponentials. This approach uses the divide-and-conquer strategy to ...

Read More

Python- Percentage occurrence at index

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 359 Views

In this article, we will learn how to calculate the percentage occurrence of a value at a specific index in a list. This computation helps analyze data distribution and patterns by determining how frequently the value at a given index appears throughout the entire list. For Example: data = [4, 2, 3, 1, 5, 6, 7] print(f"List: {data}") print(f"Value at index 2: {data[2]}") List: [4, 2, 3, 1, 5, 6, 7] Value at index 2: 3 The value 3 occurs at index 2 and appears only once in the entire list. The ...

Read More

Finding the Peak Signal-to-Noise Ratio (PSNR) using Python

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 4K+ Views

Peak Signal-to-Noise Ratio (PSNR) is a widely used metric to measure the quality of digital signals, particularly for images and video. It quantifies the difference between original and distorted versions of a signal, measuring the amount of noise added through compression, transmission, or processing. PSNR is utilized in multimedia applications, video compression, and image processing. In this article, we'll explore two methods for calculating PSNR in Python. Understanding Peak Signal-to-Noise Ratio PSNR is a standard metric for evaluating image or video quality. It's frequently used in compression algorithms to compare the quality of compressed output against the original ...

Read More

Python - Percentage similarity of lists

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 1K+ Views

Measuring the similarity between two lists is a common task in Python applications like data analysis, text processing, and recommendation systems. This article explores two methods to calculate percentage similarity between lists based on shared elements. List similarity is determined by analyzing overlap or shared elements between lists. This provides a numerical assessment of how much two lists have in common, expressed as a percentage. The choice of method depends on whether you need to handle duplicates and how you want to calculate the similarity ratio. Method 1: Using Set Intersection This approach uses Python's set data ...

Read More

Python - Mutual tuple subtraction in list

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 330 Views

Tuples are immutable sequences that store collections of elements in Python. Mutual tuple subtraction involves subtracting corresponding elements from pairs of tuples within a list, creating new tuples with the results. This operation is useful in scenarios like coordinate calculations, vector operations, and data transformations. We'll explore two approaches: using NumPy arrays and list comprehension with zip(). Understanding the Problem Given a list containing pairs of tuples, we want to subtract corresponding elements from each pair ? # Input: List of tuple pairs data = [((11, 22, 33), (33, 32, 11)), ((10, 20, 30), (5, ...

Read More

Python - Multiplying Selective Values

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 313 Views

In Python, multiplying selective values involves choosing specific elements from a data structure like a list and applying multiplication operations based on predefined criteria. This technique is particularly useful when you need to perform calculations on only a subset of your data. Python offers several approaches to accomplish this task efficiently. We'll explore two primary methods: using list comprehension for concise operations and using loops for more complex logic. Using List Comprehension List comprehension provides a concise way to create new lists while applying conditions and transformations simultaneously. It's ideal for selective multiplication when you need to ...

Read More

Multiplying Alternate elements in a List using Python?

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 250 Views

Multiplying alternate elements in a list is a common array manipulation task in Python programming. This involves selecting elements at even indices (0, 2, 4, ...) and calculating their product. We'll explore two approaches: iterative method and list comprehension. Arrays are fundamental data structures for storing collections of elements. Python provides powerful tools for array manipulation, and by solving the alternate element multiplication problem, we'll demonstrate elegant programming techniques. Using Iterative Approach The iterative approach uses a loop to traverse the list and multiply elements at even indices. We initialize a result variable to 1, then iterate ...

Read More

Python program to find number of likes and dislikes?

Adeeba Khan
Adeeba Khan
Updated on 27-Mar-2026 880 Views

The ability to analyze likes and dislikes on social media platforms is essential for understanding user engagement and sentiment. As a Python programmer, you'll often need to count these interactions to gauge content performance and user preferences. In this article, we'll explore two practical methods for counting likes and dislikes in Python datasets using different approaches. Approaches To count likes and dislikes in Python, we can use two effective methods ? Using the Counter class from collections Using manual loop iteration Let's examine both approaches with complete examples. Using Counter from Collections ...

Read More
Showing 1–10 of 20 articles
« Prev 1 2 Next »
Advertisements