Rajendra Dharmkar has Published 453 Articles

How to generate random strings with upper case letters and digits in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 21:06:48

588 Views

You generate random strings with upper case letters and digits in Python. Here are three different ways to do it: Using random.choices() and string.ascii_uppercase In this method, we will use the random.choices() function to randomly choose characters from the string.ascii_uppercase and string.digits strings to generate a random string. Example We ... Read More

How to find longest repetitive sequence in a string in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 21:03:50

887 Views

To find the longest repetitive sequence in a string in Python, we can use the following approach: Iterate through each character of the string and compare it with the next character. If they are same, we can increase a counter variable and continue comparing with the next character. If they ... Read More

How to extract numbers from a string in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 20:54:45

3K+ Views

There are several ways to extract numbers from a string in Python. One way to extract numbers from a string is to use regular expressions. Regular expressions are patterns that you can use to match and manipulate strings. Here's an example code snippet that uses regular expressions to extract all ... Read More

How to do multiple imports in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 20:49:45

3K+ Views

Importing modules is an essential part of programming in Python, and it's something you'll do a lot as you develop your skills. In Python, you can import multiple modules using a few different methods. Here are some examples of how to do it: Import each module on a separate line ... Read More

How to detect vowels vs consonants in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:55:01

1K+ Views

In the English alphabet, vowels are the letters a, e, i, o, and u. Examples of words that contain vowels include "apple", "elephant", "igloo", "octopus", and "umbrella". Consonants are all the other letters in the English alphabet, which include b, c, d, f, g, h, j, k, l, m, n, ... Read More

How to delete consonants from a string in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:49:21

429 Views

Here are some code examples to delete consonants from a string in Python: Using for loop and if statement One way to delete consonants from a string in Python is to loop through each character in the string and check if it is a vowel or not. Here's how you ... Read More

How to delete a character from a string using python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:44:58

599 Views

Here are some examples of how to delete a character from a string using Python. Using String Slicing One of the easiest ways to delete a character from a string in Python is to use string slicing. Here's how you can do it: Example In the first line of ... Read More

How to Convert String to JSON using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:39:21

2K+ Views

JSON (JavaScript Object Notation) is a lightweight data interchange format used to transmit data between web applications and servers. In Python, JSON data is represented as key-value pairs. The json module provides several methods for working with JSON data in Python, including dumps(), loads(), and dump(). These methods allow you ... Read More

How to check whether a string ends with one from a list of suffixes in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:17:50

223 Views

A suffix is defined as a letter or group of letters added at the end of a word to make a new word. Let's say you have a list of suffixes, which are groups of letters that can be added to the end of a word to change its meaning. ... Read More

How to Convert Lowercase Letters in String to Uppercase in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 10-Aug-2023 19:10:52

754 Views

In Python, a string is a sequence of characters. It's a type of data that represents text values, such as words, sentences, or even entire documents. Strings in Python are enclosed in either single quotes ('...') or double quotes ("..."), and can include alphanumeric characters, symbols, whitespace, and more. ... Read More

Advertisements