Server Side Programming Articles - Page 2537 of 2650

Sort the words in lexicographical order in Python

Yaswanth Varma
Updated on 28-Aug-2025 12:45:34

3K+ Views

Lexicographical order is similar way the words are arranged in a dictionary. In this article, we are going to learn how to sort the words in lexicographical order, which means arranging them in alphabetical order (A-Z). Python provides built-in methods like split() and sorted() to perform this operation. Using Python split() Method The Python split() method is used to split a string by using the specified separator. This separator is a delimiter string and can be a comma, a full stop, or any other character to split a string. Syntax Following is the syntax of Python str.split() method ... Read More

Extracting email addresses using regular expressions in Python

karthikeya Boyini
Updated on 20-Jun-2020 08:41:36

5K+ Views

Email addresses are pretty complex and do not have a standard being followed all over the world which makes it difficult to identify an email in a regex. The RFC 5322 specifies the format of an email address. We'll use this format to extract email addresses from the text.For example, for a given input string −Hi my name is John and email address is john.doe@somecompany.co.uk and my friend's email is jane_doe124@gmail.comWe should get the output −john.doe@somecompany.co.uk jane_doe124@gmail.comWe can use the following regex for exatraction −[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+We can extract the email addresses using the find all method from re module. For example, ... Read More

Find all the patterns of \"10+1\" in a given string using Python Regex

Sumana Challa
Updated on 09-May-2025 12:17:34

233 Views

The term "10plus1" is a specific pattern in a binary string that starts with a digit '1' followed by at least one or more '0' and ending with a '1'. In regular expressions this pattern is represented as - 10+ 1 Using re.findall() The re.findall() method accepts a pattern and a string as parameters, finds the given pattern in the entire string, and returns all the matches in the form of a list.To find the patterns of "10+1" in a given string, we just need to pass the same as pattern to the findall() method along with the string.Example ... Read More

Compare two strings lexicographically in C#

karthikeya Boyini
Updated on 19-Jun-2020 12:11:36

3K+ Views

To compare strings in C#, use the compare() method. It compares two strings and returns the following integer values −If str1 is less than str2, it returns -1. If str1 is equal to str2, it returns 0. If str1 is greater than str2, it returns 1.Set the two strings in the String.compare() method and compare them −string.Compare(string1, string2);ExampleYou can try to run the following code to compare two strings in C#.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {         ... Read More

Common Language Runtime (CLR) in C#.NET

Samual Sam
Updated on 19-Jun-2020 12:12:53

6K+ Views

Common Language Runtime (CLR) manages the execution of .NET programs. The just-in-time compiler converts the compiled code into machine instructions. This is what the computer executes.The services provided by CLR include memory management, exception handling, type safety, etc.Let us see the features of Common Language Runtime (CLR) in C#:ComponentsComponents in other languages can be easily worked upon with CLR.ThreadingThe CLR provides support for threads to create multithreaded applications.Class Library SupportIt has built-in types and libraries for assemblies, threading, memory management, etc.DebuggingCLR makes code debugging easier.Garbage CollectionIt provides automatic garbage collection in C#.

C# program to find the sum of digits of a number using Recursion

karthikeya Boyini
Updated on 19-Jun-2020 12:13:42

372 Views

Let’s say we have set the number for which we will find the sum of digits −int val = 789; Console.WriteLine("Number:", val);The following will find the sum of digits by entering the number and checking it recursively −public int addFunc(int val) {    if (val != 0) {       return (val % 10 + addFunc(val / 10));    } else {       return 0;    } }ExampleThe following is our code to find the sum of digits of a number using Recursion in C#.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {   ... Read More

C# Program to find whether the Number is Divisible by 2

Samual Sam
Updated on 19-Jun-2020 12:14:32

7K+ Views

If the remainder of the number when it is divided by 2 is 0, then it would be divisible by 2.Let’s say our number is 5, we will check it using the following if-else −// checking if the number is divisible by 2 or not if (num % 2 == 0) {    Console.WriteLine("Divisible by 2 "); } else {    Console.WriteLine("Not divisible by 2"); }ExampleThe following is an example to find whether the number is divisible by 2 or not.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class MyApplication {       static ... Read More

C# Program to Create a Thread Pool

karthikeya Boyini
Updated on 19-Jun-2020 11:36:47

662 Views

For a thread pool, create more than two functions and queue methods for execution.Firstly, create a method like −public void one(object o) {    for (int i = 0; i

C# Program to create a Simple Thread

Samual Sam
Updated on 19-Jun-2020 11:38:02

567 Views

To create a thread, I have created a function −public void myThread() {    for (int i = 0; i < 3; i++) {       Console.WriteLine("My Thread");    } }The above function is called to create a thread and a new ThreadStart delegate is created −Demo d = new Demo(); Thread thread = new Thread(new ThreadStart(d.myThread));ExampleCreate a simple thread using the following code.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; class Demo {    public void myThread() {       for (int i = 0; i < 3; i++) {         ... Read More

C# program to find the maximum of three numbers

karthikeya Boyini
Updated on 19-Jun-2020 11:38:44

14K+ Views

Firstly, let’s set the three numbers −int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.ExampleYou can try to run the following code to find the maximum of three numbers.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {          int ... Read More

Advertisements