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 on Trending Technologies
Technical articles with clear explanations and examples
Python program that renders a dictionary from two list with K values
A Dictionary is an unordered collection of data structure which stores the elements as key and value. It is mutable and in other programming languages Dictionaries are also known as associative arrays, hash maps, or hash tables. The key is unique and the values can be a single element or a list of elements with duplicates. A Dictionary can be created using curly braces {} or by using the built-in function dict(). Let's see an example of creating a dictionary in Python ? Example student = { 'name': 'Tutorialspoint', ...
Read MoreProgress Bars in Python
Progress bars in Python are visual indicators that provide feedback on the progress of a task or operation. They are especially useful for long-running processes or iterations where it's helpful to show how much work has been completed and how much is remaining. A progress bar typically consists of a visual representation, such as a horizontal bar or textual display, which dynamically updates to reflect the task's progress. It also includes additional information like completion percentage, estimated time remaining, and relevant status messages. Progress bars serve several important purposes: Visual Feedback − Shows ...
Read MoreProgramming Paradigms in Python
Programming paradigm is a specific approach or style of programming that provides a framework for designing and implementing computer programs. It encompasses a set of principles, concepts, and techniques that guide the development process and the structure of the code. Different paradigms have different ways of solving problems, organizing code, and expressing computations. Python supports multiple programming paradigms, making it a versatile language that allows developers to choose the most appropriate approach for their specific problem. Procedural Programming Procedural programming focuses on dividing a program into a set of procedures or functions. In Python, we can define ...
Read MoreProgram to calculate Dooms Day for a year
The doomsday algorithm is a mathematical method developed by John Horton Conway to determine the day of the week for any given date. It's based on the concept that certain dates within each year always fall on the same day of the week, called the doomsday. The doomsday occurs on the following memorable dates − January 3rd (January 4th in leap years) February 28th (February 29th in leap years) March 7th April 4th May 9th June 6th July 11th August 8th September 5th October 10th November 7th December 12th Algorithm Steps Step 1: Calculate ...
Read MoreUnion Operation of two Strings using Python
The union operation on strings combines two strings while removing duplicate characters. Python provides several approaches to perform string union operations, each with different characteristics and use cases. Using Sets Sets automatically remove duplicate elements, making them ideal for union operations ? def string_union_sets(first, second): set1 = set(first) set2 = set(second) union_result = set1.union(set2) return ''.join(union_result) # Example first = "What" second = "Where" result = string_union_sets(first, second) print(f"Union of '{first}' and '{second}': {result}") Union of ...
Read MoreRemoving the Initial Word from a String Using Python
Removing the first word from a string is a common text processing task in Python. This tutorial covers five effective methods: split(), regular expressions, find(), space delimiter, and partition(). Method 1: Using split() Function The split() method divides the string into a list of words, then we join everything except the first element ? def remove_first_word(string): words = string.split() if len(words) > 1: return ' '.join(words[1:]) else: return ...
Read MoreRemove the given Substring from the End of a String using Python
When working with strings in Python, you may need to remove a specific substring from the end of a string. Python provides several built-in methods to accomplish this task efficiently, from simple string methods to regular expressions. Using endswith() Method The endswith() method checks if a string ends with a specific substring, making it perfect for conditional removal ? def remove_substring(string, substring): if string.endswith(substring): return string[:len(string)-len(substring)] else: return string # Example ...
Read MoreRemove Substring list from String using Python
Removing multiple substrings from a string is a common task in Python text processing. Python provides several approaches including replace(), regular expressions, list comprehension, and the translate() method. Using replace() Method The simplest approach is to iterate through substrings and use replace() to remove each one ? def remove_substrings_replace(main_string, substrings_to_remove): for substring in substrings_to_remove: main_string = main_string.replace(substring, "") return main_string text = "Hello, everyone! This is a extra string just for example." unwanted = ["everyone", "extra", "just"] result = ...
Read MoreRemove Spaces from Dictionary Keys using Python
Dictionary keys with spaces can cause issues when accessing data programmatically. Python provides several methods to remove spaces from dictionary keys: creating a new dictionary, modifying existing keys, using dictionary comprehension, and handling nested dictionaries with recursion. Method 1: Creating a New Dictionary The simplest approach is to create a new dictionary with space-free keys while preserving the original values ? def remove_spaces(dictionary): modified_dictionary = {} for key, value in dictionary.items(): new_key = key.replace(" ", "") ...
Read MorePython - Values till False Element
Sometimes we need to process elements from a collection until we encounter a False element. Python provides several approaches: loops, itertools.takewhile(), list comprehension, and generators. Using For Loop The most straightforward approach is using a for loop with a break statement when a False element is found ? def values_till_false(collection): result = [] for element in collection: if not element: break ...
Read More