Found 26504 Articles for Server Side Programming

CMY and CMYK Color Models using Python

Niharika Aitam
Updated on 02-Aug-2023 17:38:23

2K+ Views

The CMY and CMYK color models are subtractive color models used in printing and graphic design. In Python, we can work with these color models using various libraries and tools. Let's see each color model in detail. CMY color model The CMY color model, also known as the subtractive color model, which is a system used for mixing colors in various applications like printing, painting, and graphic design. CMY stands for Cyan, Magenta, and Yellow, which are the primary colors in this model. In the CMY color model, colors are created by subtracting different amounts of cyan, magenta, and yellow ... Read More

Python - Check if a string matches regex list

Niharika Aitam
Updated on 02-Aug-2023 17:37:34

13K+ Views

A regular expression is also referred as regex, which is a sequence of characters that forms a search pattern. It's one of the powerful tools used for pattern matching and manipulating strings. In python we are having a module called re which helps to form a regular expression. Regex patterns consist of ordinary characters such as letters, digits and special characters called metacharacters. Meta Characters have special meanings and allow us to define complex search patterns. The below are some commonly used meta characters in python regular expressions. . (dot) − Matches any single character except a newline. ^ ... Read More

How to change the figure style to Darkgrid in Seaborn?

Niharika Aitam
Updated on 02-Aug-2023 17:34:00

609 Views

Seaborn provides several built-in figure styles that we can choose from to enhance the visual appearance of our plots. These styles affect various elements such as colors, grid lines, background, and fonts. To set the figure style in Seaborn, we can use the sns.set_style() function. The following are the available figure styles in Seaborn library. Darkgrid − This style features a dark gray background with grid lines, which helps in focusing attention on the data points. Whitegrid − This style is similar to "darkgrid" but with a white background, making it suitable for plots with lighter color schemes. Dark ... Read More

Finding the Common items among Python dictionaries

Niharika Aitam
Updated on 02-Aug-2023 17:33:27

192 Views

A Dictionary is one of the unordered data structures available in python to store the data in the key and value pair. It is also known as Associative array or Hash map in other programming languages. The dictionary is represented using the curly braces {} and the key and value are separated using a colon “:” The keys in the dictionary are unique and the values can be of duplicates. To access the elements of the dictionary we will use the keys. Example The following is the example of creating a dictionary using the dic() method and curly braces {} available ... Read More

Sorting Arrays in PHP

Pradeep Kumar
Updated on 02-Aug-2023 12:53:13

3K+ Views

What is Sorting? Sorting is the process of arranging a collection of items or data elements in a particular order, usually based on some predefined criteria. It is a fundamental operation in computer science and is used extensively in various algorithms and applications. The purpose of sorting is to bring organization and structure to a set of data so that it can be easily searched, accessed, or presented in a meaningful way. By arranging the data in a specific order, sorting allows for efficient searching, comparison, and retrieval operations. Sorting can be performed on various types of ... Read More

Sort Array of Objects by Object Fields in PHP

Pradeep Kumar
Updated on 02-Aug-2023 12:44:10

4K+ Views

There are several ways to sort an array of objects by object fields in PHP. Here are some common approaches: Using usort() function with a custom comparison function Implementing a custom sorting algorithm Utilizing the array_multisort() function Using usort() Function with a Custom Comparison Function Here's an example of using the usort() function with a custom comparison function to sort an array of objects by object fields in PHP: // Custom comparison function function compareByField($a, $b) { // Replace 'fieldName' with ... Read More

Sort a Multidimensional Array by Date Element in PHP

Pradeep Kumar
Updated on 02-Aug-2023 12:38:50

6K+ Views

In PHP, you can sort a multidimensional array by a specific element, such as a date, using various approaches. Let's explore a few different methods. Using array_multisort() Using a custom comparison function Using the array_multisort() function with a callback Using array_multisort() Here's an example of sorting a multidimensional array by a date element using array_multisort(): $multiArray = array( array('date' => '2023-06-01', 'name' => 'John'), array('date' => '2023-05-15', 'name' => 'Alice'), array('date' => '2023-06-10', 'name' => ... Read More

Saving an Image from URL in PHP

Pradeep Kumar
Updated on 02-Aug-2023 12:35:32

11K+ Views

There are several ways to save an image from a URL in PHP. Here are three common methods: Using file_get_contents() and file_put_contents() Using cURL Using the GD library Using file_get_contents() and file_put_contents() Using file_get_contents() and file_put_contents() is a straightforward method to save an image from a URL in PHP. Here's an Example $url = "https://example.com/image.jpg"; $image = file_get_contents($url); file_put_contents("path/to/save/image.jpg", $image); In this code snippet, file_get_contents() is used to retrieve the contents of the image file from the specified URL. ... Read More

Python program to concatenate two Integer values into one

Niharika Aitam
Updated on 02-Aug-2023 12:28:43

5K+ Views

An integer is a data type in Python that represents whole numbers without any fractional or decimal parts. In Python, integers are a built-in data type, and they can be used to perform arithmetic operations, store numerical values, and represent counts, indices, or other discrete quantities. Integers in Python have a wide range of applications, including mathematical calculations, indexing and slicing sequences e.g., lists, strings, and controlling loops and iterations. They provide a fundamental building block for numerical computations and algorithm implementations in Python. The following are the examples of integers in python. x = 5 y = -10 z ... Read More

Python program to Concatenate Kth index words of String

Niharika Aitam
Updated on 02-Aug-2023 12:27:32

142 Views

The string is the immutable data structure which stores the data in the string format. It can be created by using the str() method or by giving the data in the single or double quotes. It accesses the elements of the string we use indexing. In Indexing we have negative indexing and positive indexing where as in negative indexing we will access the last element using -1 and (–length of string) to the first element. In positive indexing we will give 0 to the first element and (length of string - 1) to the last element. Now, in this article ... Read More

Advertisements