Found 27104 Articles for Server Side Programming

Abbreviate given String by Replacing all Characters with Length Except the First and Last

Shubham Vora
Updated on 14-Aug-2023 13:36:13

105 Views

In this problem, we need to transform the string of a length greater than 2 into its abbreviation form. We can use the ‘length’ property of the string to count the total number of middle characters in the string, and we can first and last characters using the respected index value. Problem statement − We have given a string str of length greater than or equal to 2 and need to convert the string into its abbreviation form. The abbreviation form of the string is as shown here: first character + the total number of middle characters + last ... Read More

Converting Speech to Text to Text to Speech in Python

Priya Sharma
Updated on 14-Aug-2023 12:43:32

2K+ Views

In today's digital age, the ability to seamlessly convert between speech and text has become increasingly important. From voice-controlled assistants to transcription services, this functionality is in high demand across a wide range of applications. Python, with its extensive library ecosystem, offers powerful tools and APIs that make it relatively straightforward to implement speech-to-text and text-to-speech conversions. In this blog post, we will explore how to leverage Python to convert speech to text and text to speech, empowering developers to create innovative applications that bridge the gap between spoken and written communication. Converting Speech to Text The first step ... Read More

Sorting given Character Array using Linked List

Shubham Vora
Updated on 14-Aug-2023 13:32:25

152 Views

In this problem, we need to sort the given array of characters using a linked list. We can use bubble sort, selection sort, merger sort, etc. techniques to sort the array. Here, we will convert the array into the linked list first and then use the selection sort and bubble sort techniques to sort the array. Problem statement − We have given an array arr[] of length N. The array contains lowercase alphabetical characters. We need to sort the array using the linked list. Sample examples Input arr[] = {'e', 's', 'a', 'x', 'c', 'e', 'f', 'p', 'b', 'n', ... Read More

Python3 Program for Minimum Rotations Required to get the Same String

Shubham Vora
Updated on 14-Aug-2023 13:28:47

51 Views

In this problem, we need to find the total number of rotations to get the same string. The naïve approach to solving the problem is that we can keep rotating the string. We can print the total number of required rotations if we find the same string. Also, other approaches take the substring from the string and make it equal to the original string. After that, we can get rotations using the substring length. Problem statement − We have given string str. We need to find the total number of rotations required to get the same string again. Sample examples ... Read More

AttributeError in Python

Priya Sharma
Updated on 14-Aug-2023 12:40:53

156 Views

Python is a versatile and powerful programming language that allows developers to build a wide range of applications. However, like any programming language, Python is not immune to errors. One common error that developers encounter is the AttributeError. Let’s explore what an AttributeError is, why it occurs, and how to handle it effectively. What is an AttributeError? An AttributeError is an exception that occurs when an object does not have a particular attribute or method that is being accessed. It is raised when an invalid attribute reference or assignment is made to an object. Reasons for AttributeError An AttributeError can ... Read More

Age Calculator using Python Tkinter

Priya Sharma
Updated on 14-Aug-2023 12:39:34

1K+ Views

An Age Calculator is a handy tool that allows users to determine their age based on their date of birth. By inputting the date, it provides the number of days, months, and years since their birth, giving a precise measure of their journey through time. Python, known for its simplicity and versatility, serves as the programming language of choice for our Age Calculator. Alongside Python, we will be utilizing Tkinter, a popular GUI (Graphical User Interface) library, to create an intuitive and interactive user interface for our application. Prerequisites Before we dive into building our Age Calculator using Python Tkinter, ... Read More

Python Program for Generating Lyndon Words of Length n

Shubham Vora
Updated on 14-Aug-2023 13:27:24

57 Views

In this problem, we will find all Lyndon words using the array's alphanumeric characters. Before we start, let’s understand the definition of the Lyndon word. All words are Lyndon words which are strictly lexicographically smaller than all of their rotations. Here are examples of Lyndon words. ab − The ‘ab’ is strictly lexicographically smaller than all of its permutations which is ‘ba’. 89 − The rotations of ‘89’ is ‘98’, which is strictly lexicographically larger than ‘89’. abc − The rotations of ‘abc’ are ‘bca’ and ‘cab’, which are strictly greater than ‘abc’. Here ... Read More

PHP Program for Minimum Rotations Required to get the Same String

Shubham Vora
Updated on 14-Aug-2023 13:26:07

49 Views

In this problem, we need to achieve the same string by performing the rotations of the string and need to count rotations. There can be different ways to solve the problem, but here we will learn some best approaches in PHP. The first approach uses the rotational substring, and another approach divides the string into two parts from the particular index. Problem statement − We have a string str containing n characters. We have to find the minimum rotations of string we should perform to achieve the same string again. Sample examples Input str = "bcbc"; Output ... Read More

Adding custom values key in a List of dictionaries in Python

Priya Sharma
Updated on 14-Aug-2023 12:34:14

133 Views

Working with structured data is a common task in programming, and Python provides powerful data structures like lists and dictionaries to handle such data effectively. In many scenarios, you may come across situations where you need to augment the existing data structure by adding custom key-value pairs. This can be particularly useful when you want to associate additional information or metadata with the existing data. In Python, a list is an ordered collection of items, and each item in the list can be a dictionary—an associative data structure that stores key-value pairs. By adding custom key-value pairs to the dictionaries ... Read More

Minimize Replacement of Bits to make the Count of 01 Substring Equal to 10 Substring

Shubham Vora
Updated on 14-Aug-2023 13:23:50

65 Views

Problem statement − We have given the binary string of length N. We need to find the minimum number of flipping characters required to get the balanced binary string. Flipping characters means converting 0 to 1 and 1 to 0. If any string contains an equal number of ‘01’ and ‘10’ pairs, we can say that string is a balanced binary string. Sample examples Input str = "001010" Output 0 Explanation − The string contains 2 ‘01’ and ‘10’ pairs. So, we don’t need to perform any flipping operations. Input str = ‘00001’ ... Read More

Advertisements