Found 34490 Articles for Programming

C# program to implement FizzBuzz

George John
Updated on 20-Apr-2020 08:06:26

3K+ Views

Implementation of FizzBuzz involves printing numbers from 1 to 100. If the numbers are multiples of 3 then Fizz is printed. If they are multiples of 5, then Buzz is printed and if they are multiples of both 3 and 5 then FizzBuzz is printed.A program that demonstrates the implementation of FizzBuzz is given as follows.Example Live Demousing System; namespace FizzBuzzDemo {    public class example {       static void Main(string[] args) {          for (int i = 1; i

How to get synonyms/antonyms from NLTK WordNet in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

2K+ Views

The WordNet is a part of Python's Natural Language Toolkit. It is a large word database of English Nouns, Adjectives, Adverbs and Verbs. These are grouped into some set of cognitive synonyms, which are called synsets. To use the Wordnet, at first we have to install the NLTK module, then download the WordNet package. $ sudo pip3 install nltk $ python3 >>> import nltk >>>nltk.download('wordnet') In the wordnet, there are some groups of words, whose meaning are same. In the first example, we will see how wordnet returns meaning and other details of a word. Sometimes, if some ... Read More

Heap Sort in C#

Ankith Reddy
Updated on 26-Jun-2020 14:27:51

2K+ Views

Heap Sort is a sorting algorithm that makes use of the heap data structure. Each time the root element of the heap i.e. the largest element is removed and stored in an array. It is replaced by the rightmost leaf element and then the heap is reestablished. This is done until there are no more elements left in the heap and the array is sorted.A program that demonstrates heap sort in C# is given as follows.Example Live Demousing System; namespace HeapSortDemo {    public class example {       static void heapSort(int[] arr, int n) {         ... Read More

Chaining comparison operators in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

710 Views

Sometimes we need to use more than one condition checking in a single statement. There are some basic syntax for these kind of checking is x < y < z, or if x < y and x < z etc. Like other languages, there are some basic comparison operators in Python. These comparison operators are =, ==, !=, is, is not, in, not in. The precedence of these operators are same, and the precedence is lesser than arithmetic, bitwise and shifting operators. These operators can be arranged arbitrarily. They will be used as a chain. So for an example, if ... Read More

Insertion Sort in C#

Arjun Thakur
Updated on 26-Jun-2020 14:30:08

4K+ Views

Insertion Sort is a sorting algorithm that takes an element at a time and inserts it in its correct position in the array. This process is continued until the array is sorted.A program that demonstrates insertion sort in C# is given as follows.Example Live Demousing System; namespace InsertionSortDemo {    class Example {       static void Main(string[] args) {          int[] arr = new int[10] { 23, 9, 85, 12, 99, 34, 60, 15, 100, 1 };          int n = 10, i, j, val, flag;          Console.WriteLine("Insertion Sort");   ... Read More

Quickly convert Decimal to other bases in Python

AmitDiwan
Updated on 11-Aug-2022 11:31:07

1K+ Views

To quickly convert Decimal to other based, we will be using the Built-in functions in Python − Decimal to Binary − bin() Decimal to Octal − oct() Decimal to Hexadecimal − hex() Decimal number system has base 10 as it uses 10 digits from 0 to 9. In decimal number system, the successive positions to the left of the decimal point represent units, tens, hundreds, thousands, and so on. Binary uses two digits, 0 and 1. Also called as base 2 number system Each position in a binary number represents a 0 power of the base (2). Last ... Read More

Selection Sort program in C#

Chandu yadav
Updated on 26-Jun-2020 14:32:38

5K+ Views

Selection Sort is a sorting algorithm that finds the minimum value in the array for each iteration of the loop. Then this minimum value is swapped with the current array element. This procedure is followed until the array is sorted.A program that demonstrates selection sort in C# is given as follows.Example Live Demousing System; public class Example {    static void Main(string[] args) {       int[] arr = new int[10] { 56, 1, 99, 67, 89, 23, 44, 12, 78, 34 };       int n = 10;       Console.WriteLine("Selection sort");       Console.Write("Initial array ... Read More

Implementing Photomosaics in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

546 Views

The photomosaic is a technique, where we can split our image into a grid of squares. Each square will be replaced by some other images or colors. So when we want to see the actual image from a certain distance, we can see the actual image, but if we come closer, we can see the grid of different colored blocks. In this case we are using a Python module called photomosaic. Using this module, we can easily create some photomosaics. To install it please follow this link. It will also download the scikit learn module. sudo pip3 install photomosaic ... Read More

How to obtain the highest occurring character in a String using C#?

George John
Updated on 26-Jun-2020 14:33:01

3K+ Views

The highest occurring character in a string is one that occurs most number of times. This can be demonstrated using the following example.String: apples are red The highest occurring character in the above string is e as it occurs 3 times, which is more than the occurrence of any other character.A program that obtains the highest occurring character in a string using C# is given as follows.Example Live Demousing System; namespace charCountDemo {    public class Example {       public static void Main() {          String str = "abracadabra";          int []charCount = ... Read More

Generating Random id's using UUID in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

711 Views

UUID is having the full form Universal Unique Identifier, it is a python library which supports 128 bits ids for generating random objects. Advantages of UUID As discussed, we can use it to generate unique random id for random objects. For cryptography and hashing applications, this id can be used. For generating random documents and also addresses etc. this id can be used. Method1 Using uuid1() Example code import uuid print ("Random id using uuid1() is : ", end="") print (uuid.uuid1()) Output Random id using uuid1() is : 4adeede2-e5d8-11e8-bd27-185e0fd4f8b3 Representations of uuid1() bytes − ... Read More

Advertisements