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 Devesh Chauhan
47 articles
Protected variable in Python
In programming, the concept of protected variables is used to create an access control system. In this system, we establish a hierarchy or level of access control. This concept solidifies the basis of object-oriented programming. The technical meaning of a protected variable remains the same but the syntax and behaviour may vary between different programming languages. Python follows the conventional logic of accessing and manipulating the attributes and methods, but the representation and degree of enforcement of access control is a little different. Understanding Protected Variables in Python Protected variables in Python manage the internal use of ...
Read MorePython Program to Extract Strings between HTML Tags
HTML tags are used to design the skeleton of websites. We pass information and upload content in the form of strings enclosed within the tags. The strings between the HTML tags determines how the element will be displayed and interpreted by the browser. Therefore, the extraction of these strings plays a crucial role in data manipulation and processing. These strings reveal the hidden pattern and logic behind the construction of a webpage. In this article, we will explore different methods to extract strings between HTML tags. Understanding the Problem We have to extract all the strings between ...
Read MorePython Program to Extract String Till First Non-Alphanumeric Character
Python strings are sequences of characters that represent information or data. A normal string can contain various characters that are enclosed within single or double quotes, but an alphanumeric string only consists of digits and letters. Both alphanumeric and non-alphanumeric strings are used in various scenarios including password protection, data processing, and validation. In this tutorial, we will extract a substring from the beginning of a string until we encounter the first non-alphanumeric character. Understanding the Problem We need to extract a substring from an original string before we encounter a non-alphanumeric character. Let's understand this with ...
Read MorePython program to extract N largest dictionaries keys
A Python dictionary is a data structure that stores data in key-value pairs, where each value is associated with a unique key. In many scenarios, we need to extract the N largest keys from a dictionary based on their numerical values. This article explores different methods to extract N largest dictionary keys, ranging from basic iteration approaches to more efficient built-in functions. Understanding the Problem Given a dictionary with numeric keys, we need to find and return the N largest keys in descending order. Example # Sample dictionary sample_dict = {12: 10, 22: 12, ...
Read MorePython Program to Extract Mesh Matching Strings
Pattern recognition is an important programming concept. It allows us to retrieve specific data that satisfies a particular condition or match a particular sequence. This principle is helpful in various fields including language processing and image processing. String matching helps us to extract meaningful information from a large collection of data. In this article, we will be discussing a similar concept of extracting mesh matching strings from a given list of strings. Mesh matching focuses on the extraction of "similar" strings of equal length that follow a specific pattern. Understanding the Problem The main concept is to ...
Read MorePython program to extract key-value pairs with substring in a dictionary
Dictionaries in Python are data structures that store data in the form of key-value pairs. Each key is unique and it is associated with different values. A dictionary helps us to access and retrieve data efficiently allowing a programmer to build optimized code. Specific key-value pairs can be extracted from a given dictionary based on different requirements. This selective item extraction helps us to produce a dictionary consisting of relevant information. In this article, we will be discussing a similar concept of item extraction from a dictionary based on a reference substring. Understanding the Problem We will ...
Read MorePython program to extract dictionary items for custom values
Custom values are specific values that are defined and selected under certain criteria. In a large and complex dataset, specification is very important for constructing an optimized program and therefore extraction of relevant data becomes very important. We can pass a reference list according to which the values can be extracted. This reference list has its own implications as it stores concise information. In this article we will be discussing a similar concept of extracting dictionary items (both keys and values) for a custom data passed through a list. Understanding the Problem We will create a dictionary ...
Read MorePython program to extract a single value from JSON response
Value extraction is a very popular programming concept and it is used in a wide variety of operations. However extracting values from a JSON response is a different concept all together. It helps us to build logic and target specific values in a complex dataset. This article will explain the various methods that can be used to extract a single value from a JSON response. What is a JSON Response? A JSON (JavaScript Object Notation) response is a widely accepted data format through which a server responds to a client's request. Whenever a client requests for certain APIs ...
Read MorePython program to equal character frequencies
Python provides numerous built-in functions for string manipulation and analysis. In this article, we'll explore how to modify an input string to equalize character frequencies, ensuring each character appears the same number of times as the most frequent character. Understanding the Problem Our task is to modify a string so that each character has equal frequencies. We find the maximum occurring character and adjust all other characters to match that frequency. Example Scenario Consider this input string: input_str = "thisisateststring" print("Original string:", input_str) # Count character frequencies from collections import Counter freq = ...
Read MorePython program to draw a bar chart using turtle
Graphical representation of data provides an enhanced understanding of complex sub-structures and helps us easily interpret hidden patterns and trends. Python offers a built-in module called turtle that allows us to create visual graphics programmatically. The turtle module is a built-in Python library that enables drawing graphics on a turtle graphics screen. In this article, we will create a bar chart using the turtle module ? Understanding the Turtle Module The turtle module uses a virtual turtle object to create graphics. This turtle can move around the screen and draw shapes. Let's explore the key functions needed ...
Read More