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
Python Articles
Page 58 of 855
Python Program to Concatenate all keys which have similar values
Python's implementation of a data structure known more commonly as an associative array is a dictionary. A dictionary is made up of a group of key-value pairs. Each key-value combination corresponds to a key and its corresponding value. In this article, we will learn how to concatenate all keys which have similar values in Python ? Methods Used The following are the various methods to accomplish this task: Using defaultdict() and join() functions Using dictionary comprehension, groupby() and join() functions Example Assume we have taken an input dictionary. We will now concatenate ...
Read MorePython Program to Add K between case shifts
In Python, we can add a symbol between case shifts (transitions from uppercase to lowercase or vice versa) using built-in string methods like isupper(), islower(), and join(). A case shift occurs when consecutive characters change from uppercase to lowercase or lowercase to uppercase. Understanding Case Shifts Let's see what case shifts look like with an example ? # Example of case shifts in a string text = "tUtoRialsPoInt" print("Original string:", text) print("Case shifts occur between:") print("t -> U (lowercase to uppercase)") print("U -> t (uppercase to lowercase)") print("o -> R (lowercase to uppercase)") ...
Read MorePrint all repeating digits present in a given number in sorted order
Finding repeating digits in a number is a common programming task. Python provides several built-in functions like count(), Counter(), and operator.countOf() that can efficiently identify and sort duplicate digits. Problem Statement Given a number, we need to find all digits that appear more than once and display them in sorted order. Input inputNum = 5322789124199 Expected Output 1 2 9 In the input number 5322789124199, digits 1, 2, and 9 appear multiple times, so they are displayed in ascending order. Method 1: Using count() Function The count() method returns ...
Read MoreHow to Convert Dictionary to Concatenated String using Python?
A dictionary in Python is a built-in data structure that allows you to store and retrieve values using unique keys. Converting a dictionary to a concatenated string means combining all keys and values into a single string without separators. For example ? Input = {'one': 1, 'two': 2, 'three': 3} Output = one1two2three3 Let's explore different methods to achieve this conversion. Using a Loop and F-string This method iterates through the dictionary's key-value pairs and concatenates them using an f-string ? dictionary = {'one': 1, 'two': 2, 'three': 3} concatenated_string = ...
Read MoreConvert Image to String and vice-versa in Python
Converting images to string format and back is a common requirement in Python applications. This process involves encoding image binary data into text format for storage, transmission, or processing, then decoding it back to reconstruct the original image. Converting Image to String − This involves transcribing binary image data into text format using encoding schemes like Base64. This conversion is useful for transmitting images through APIs, storing in databases, or sending over text-based protocols. Converting String to Image − This reverses the process by decoding the encoded string back into binary data to reconstruct the original image file. ...
Read MoreHow to Create Custom Turtle shapes in Python?
Python's Turtle library is used for generating 2D graphics and animations. It has a very simple interface with help of which we can create shapes and patterns on the screen. It comes with some built-in shapes like squares, circles, triangles etc. However, we can even create our own shapes with the help of Turtle. In this article, we are going to see how to create custom turtle shapes in python. Before going forward with the creating custom shapes we need to install Turtle on the system and this can be done by simply using the following command − ...
Read MoreHow to Create Bottom Navigation using Kivymd and Python?
KivyMD is a commonly known library of Python which offers us with a collection of Material Design (MD) compliant widgets. These widgets can be used along with the kivy framework which is another library and is used for creating multi-touch applications. The large number of UI elements that kivyMD provides us with, include buttons, cards, dialogs, menus and many more such elements, all of which are designed to give an appealing look and feel. A navigation bar is a UI element that allows users to "navigate" between different screens/sections of an application. They are normally present on the top ...
Read MoreHow to add Site Header, Site Title, Index Title in a Django Project?
Django templates use a powerful template system that allows you to create reusable layouts with dynamic content. Adding a site header, site title, and index title helps users navigate and understand your website's purpose. This tutorial shows how to implement these elements using Django's template inheritance system. Template Structure Overview Django templates use template blocks to define sections that can be overridden in child templates. The basic approach involves creating a base template with placeholder blocks, then extending it in specific pages. Step 1: Create Base Template First, create a base template that defines the overall ...
Read MorePython Program to Increment Numeric Strings by K
A numeric string in Python is a string that represents a numerical value using digits, signs, and decimal points, allowing for mathematical operations and data processing. In this article, we will learn different methods to increment numeric strings by K while keeping non-numeric strings unchanged. Problem Overview Given a list of strings containing both numeric and non-numeric values, we need to increment only the numeric strings by a given value K ? Example Input: input_list = ["10", "hello", "8", "tutorialspoint", "12", "20"] k = 5 Expected Output: ['15', 'hello', '13', ...
Read MorePython Program to find the key of Maximum Value Tuples in a Dictionary
Finding the key of the maximum value tuples in a Python dictionary means identifying the key associated with the tuple that has the highest value among all the tuples in the dictionary. This is useful for retrieving the most significant or relevant information from the data. Problem Statement Given a dictionary with tuples as values, we need to find the key corresponding to the tuple with the maximum value (typically the second element of the tuple). Example Input: inputDict = {'hello': ("p", 2), 'tutorialspoint': ("c", 15), 'python': ("k", 8)} print("Input dictionary:", inputDict) ...
Read More