Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Hafeezul Kareem
Page 7 of 26
Audio processing using Pydub and Google Speech Recognition API in Python
Audio processing is essential for converting speech to text in applications like transcription services and voice assistants. This tutorial demonstrates how to use Pydub for audio manipulation and Google Speech Recognition API to extract text from audio files. Installing Required Libraries First, install the necessary packages using pip − pip install pydub speechrecognition audioread How It Works The process involves two main steps: Audio Chunking: Breaking large audio files into smaller segments for better processing Speech Recognition: Converting each audio chunk to text ...
Read MoreBarnsley Fern in Python
The Barnsley Fern is a fractal pattern created by mathematician Michael Barnsley that resembles the shape of a natural fern. It is generated using four mathematical transformations known as an Iterated Function System (IFS), where each transformation has different probabilities of being selected. Mathematical Foundation The Barnsley Fern uses four affine transformations, each with the general form ? f(x, y) = [a b] [c d] [x] [y] + [e] [f] The four transformations ...
Read MoreBasic Python Programming Challenges
In this tutorial, we will create a Python quiz program that generates random arithmetic questions. The program asks users to solve basic math operations and provides a final score based on correct answers. Challenge Overview We need to build a program that: Generates random arithmetic operations (+, -, *, /, //, %) Takes user input for the number of questions Evaluates user answers and provides feedback Displays the final score Complete Solution Here's the complete arithmetic quiz program ? # importing random and operator modules import random import operator # ...
Read MoreData analysis and Visualization with Python program
Data analysis and visualization are essential skills in Python programming. This tutorial covers the fundamentals using two powerful libraries: pandas for data manipulation and matplotlib for creating visualizations. Installation Install the required packages using pip − pip install pandas matplotlib Introduction to Pandas Pandas is an open-source library that provides high-performance data analysis tools. It offers data structures like DataFrame and Series for handling structured data efficiently. Creating DataFrames A DataFrame is a two-dimensional data structure with labeled rows and columns. Here's how to create one from scratch ? ...
Read MoreProgram to reverse an array up to a given position in Python
In this tutorial, we will learn how to reverse an array up to a given position. This means reversing elements from index 0 to index (n-1), while keeping the remaining elements in their original positions. Problem Statement Given an array of integers and a number n, reverse the elements from the 0th index to (n-1)th index ? Input: array = [1, 2, 3, 4, 5, 6, 7, 8, 9], n = 5 Output: [5, 4, 3, 2, 1, 6, 7, 8, 9] Method 1: Using Swapping This approach swaps elements from both ...
Read MorePython program to remove leading zeros from an IP address
In this tutorial, we will write a Python program to remove leading zeros from an IP address. For example, if we have an IP address 255.001.040.001, we need to convert it to 255.1.40.1. Approach The solution involves these steps − Split the IP address by dots using split() Convert each part to integer (automatically removes leading zeros) Convert back to strings and join with dots Example Here's how to remove leading zeros from an IP address − # Initialize IP address with leading zeros ip_address = "255.001.040.001" # Split using ...
Read MorePython program to merge two Dictionaries
In this tutorial, we are going to learn how to combine two dictionaries in Python. Let's see different ways to merge two dictionaries. Using update() Method The update() method is an inbuilt dictionary method that merges one dictionary into another. It returns None and modifies the original dictionary in place ? # initializing the dictionaries fruits = {"apple": 2, "orange": 3, "tangerine": 5} dry_fruits = {"cashew": 3, "almond": 4, "pistachio": 6} # updating the fruits dictionary fruits.update(dry_fruits) # printing the fruits dictionary # it contains both the key: value pairs print(fruits) ...
Read MorePython program to find all close matches of input string from a list
In this tutorial, we will find all strings from a list that closely match a given input string. A close match means either the string starts with the input element or the input element starts with the string. Problem Statement Given a list of strings and an input element, find all strings that have a close match with the element ? Input: strings = ["Lion", "Li", "Tiger", "Tig"] element = "Lion" Output: Lion Li Algorithm We can solve this using the startswith() method with the following steps ? Initialize ...
Read MoreProgram to check if all the values in a list that are greater than a given value in Python
In this tutorial, we will check whether all the elements in a list are greater than a given number or not. For example, we have a list [1, 2, 3, 4, 5] and a number 0. If every value in the list is greater than the given value, we return True, otherwise False. Python provides multiple approaches to solve this problem efficiently. Let's explore different methods to implement this logic. Method 1: Using a Loop The basic approach involves iterating through each element and checking if any value is less than or equal to the given number ...
Read MorePermutation of a given string using the inbuilt function in Python
In this tutorial, we will find the permutation of a string using Python's built-in permutations() function from the itertools module. A permutation is a rearrangement of all characters in a string where each character appears exactly once. How It Works The itertools.permutations() method generates all possible arrangements of the input string's characters and returns them as tuples in an iterator object. Step-by-Step Process Import the itertools module Initialize the string Use itertools.permutations() to generate all permutations Convert the iterator to a list of tuples Join each tuple to form readable strings Example ...
Read More