Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2387 of 3366
616 Views
Chunks of data move between the clients and servers using the User Datagram Protocol or UDP protocol. The two communicating endpoints need the IP address and port number to establish communication. One endpoint is known as the sender and the other is known as the receiver. In this protocol, the sender does not keep track of the sent packets and it is up to the receiver to accept or not all the packets.Sender ProgramThe below python program uses the socket module to create the sender’s program. We declare variables for IP address and Port. Then add a message to it. ... Read More
5K+ Views
Heap queue is a special tree structure in which each parent node is less than or equal to its child node. In python it is implemented using the heapq module. It is very useful is implementing priority queues where the queue item with higher weight is given more priority in processing.Create a HeapA heap queue is created by using python’s inbuilt library named heapq. This library has the relevant functions to carry out various operations on a heap data structure. Below is a list of these functions.heapify – This function converts a regular list to a heap. In the resulting heap ... Read More
3K+ Views
We can create new sequences using a given python sequence. This is called comprehension. It basically a way of writing a concise code block to generate a sequence which can be a list, dictionary, set or a generator by using another sequence. It may involve multiple steps of conversion between different types of sequences.List ComprehensionIn this method, we create a new list by manipulating the values of an existing list. In the below example we take a list and create a new list by adding 3 to each element of the given list.Examplegiven_list = [x for x in range(5)] print(given_list) ... Read More
1K+ Views
This module allows bidirectional conversions of color values between colors expressed in the RGB (Red Green Blue) and other color spaces. The three other color spaces it uses are YIQ (Luminance (Y) In-phase Quadrature), HLS (Hue Lightness Saturation) and HSV (Hue Saturation Value). All the coordinates can be between 0 and 1 except the I and Q values in the YIQ color space.The below tables shows the functions and their purpose.FunctionPurposePermitted Valuesrgb_to_yiqfrom RGB coordinates to YIQ coordinates0 to 1rgb_to_hlsfrom RGB coordinates to HLS coordinates0 to 1rgb_to_hsvfrom RGB coordinates to HSV coordinates0 to 1yiq_to_rgbfrom YIQ coordinates to RGB coordinates-1 to 1hls_to_rgbfrom ... Read More
482 Views
A class method receives the class itself as its first argument. This way we are able to call the method inside a class without first creating an instance from the class. We just use the decorator @classmethod before the declaration of the method contained in the class and then we can directly access the method. Below are the main features of classmethids.A classmethod is bound to a class and does not depend on the instantiation of a class to be used.A classmethod can modify a class which in turn propagates to all instances of the class.Using the classmethodIn the below ... Read More
2K+ Views
In Python Programming Language, Class and Instance are two of object orientation's most crucial ideas. Instances are unique objects made in accordance with the class, whereas classes are templates. The procedure is the same for all objects, although the data may vary. In this tutorial, we will learn about classes in python, how to instantiate them, what attributes are, and the differences between class and instance attribute in Python. Let’s begin with definitions – What is a Class? Classes provide a means of bundling data and functionality together in python. Creating a new class creates a new type of ... Read More
336 Views
In Python, a string is one of the data structures that is a sequence of characters enclosed within single quotes '' or double quotes "". It is immutable, i.e., once a string is created, it cannot be changed. When we want to check if both halves of the string have the same set of characters in Python, we can follow the steps below - First, based on the length of the string, we have to split the string into two halves. Next, convert each half into a set of characters using set() function. Finally, compare the two sets using ... Read More
1K+ Views
In this article, we will solve the problem of checking balanced parentheses. Let's understand the problem statement, The following are the conditions for balanced parentheses − Every opening parenthesis has a corresponding closing parentheses. Parentheses should be closed in the correct order. For example, "{[()]}" is a balanced parenthesis. condiser the same example with different arrangment "{([})]" which is unbalanced parantheses. Checking parentheses Using 'list' and 'for' loop list is one of the built-in data types in Python. A Python list is a sequence of comma-separated items, enclosed ... Read More
6K+ Views
A Gson is a json library for Java and it can be used to generate a JSON. In the initial step, we can read a JSON file and parsing to a Java object then need to typecast the Java object to a JSonObject and parsing to a JsonArray. Then iterating this JSON array to print the JsonElement. We can create a JsonWriter class to write a JSON encoded value to a stream, one token at a time. Finally, a new JSON string can be written to an existing json file. Exampleimport java.io.*; import java.util.*; import com.google.gson.*; import com.google.gson.stream.*; import com.google.gson.annotations.*; public class JSONFilewriteTest { ... Read More
5K+ Views
The @JsonAutoDetect annotation can be used at the class level to override the visibility of the properties of a class during serialization and deserialization. We can set the visibility with the properties like "creatorVisibility", "fieldVisibility", "getterVisibility", "setterVisibility" and "isGetterVisibility". The JsonAutoDetect class can define public static constants that are similar to Java class visibility levels like "ANY", "DEFAULT", "NON_PRIVATE", "NONE", "PROTECTED_AND_PRIVATE" and "PUBLIC_ONLY".Exampleimport com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import java.io.*; public class JsonAutoDetectTest { public static void main(String[] args) throws IOException { Address address = new Address("Madhapur", "Hyderabad", "Telangana"); Name name = new Name("Raja", "Ramesh"); Student student ... Read More