Server Side Programming Articles

Page 75 of 2109

Check if a String is Present in a Pdf File in Python

Mukul Latiyan
Mukul Latiyan
Updated on 27-Mar-2026 872 Views

In today's digital world, PDF files have become an essential medium for storing and sharing information. Python provides several libraries that allow us to interact with PDF files and extract information from them. One common task is to search for a particular string within a PDF file. However, the simple text-based approach shown below has significant limitations. Opening a PDF file as plain text will not work properly because PDFs contain binary data, formatting, and metadata. For real PDF processing, you should use specialized libraries like PyPDF2 or pdfplumber. Basic Text Search Approach (Limited) This approach treats ...

Read More

Change the View of Tensor in PyTorch

Mukul Latiyan
Mukul Latiyan
Updated on 27-Mar-2026 367 Views

PyTorch tensors support the view() method to reshape tensor dimensions without copying data. This is essential for deep learning operations where you need to transform tensor shapes for different layers. What is tensor.view()? The view() method returns a new tensor with the same data but different shape. It's memory-efficient because it creates a new view of the existing data rather than copying it. Syntax tensor.view(*shape) tensor.view(rows, columns) The total number of elements must remain constant. For a tensor with 12 elements, valid shapes include (12, ), (3, 4), (2, 6), etc. Basic ...

Read More

CMY and CMYK Color Models using Python

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 3K+ 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 libraries like matplotlib and PIL to create, manipulate, and visualize colors. CMY Color Model The CMY color model, also known as the subtractive color model, is a system used for mixing colors in 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 pigments ...

Read More

How to change the figure style to Darkgrid in Seaborn?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 756 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. Available Seaborn Styles 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 ...

Read More

Finding the Common items among Python dictionaries

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 275 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. Creating a Dictionary The following is the example of creating a dictionary using the dict() method ...

Read More

Python program to concatenate two Integer values into one

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 5K+ Views

An integer is a data type in Python that represents whole numbers without any fractional or decimal parts. Integers are built-in data types used for arithmetic operations, storing numerical values, and representing counts or indices. In this article, we will explore different approaches to concatenate two integers into one single integer value in Python. Using str() Function and String Concatenation This approach converts both integers to strings using str(), concatenates them with the + operator, then converts back to integer ? def concatenate_integers(a, b): concatenated = str(a) + str(b) ...

Read More

Python program to Concatenate Kth index words of String

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 198 Views

Python strings are immutable data structures that store text data. We can access string elements using indexing, where positive indexing starts from 0 and negative indexing starts from -1. When working with strings containing multiple words, we often need to extract specific words based on their positions. In this article, we'll explore different approaches to concatenate words at every Kth index position from a string using Python. Using Loops This approach splits the string into words and iterates through them, selecting words at indices that are multiples of K ? def concatenate_kth_words(string, k): ...

Read More

Python program to concatenate all Elements of a List into a String

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 868 Views

List is one of the mutable data structures available in Python which is used to store data of any datatype. It is denoted with square brackets "[]" and all the elements in the list are separated by commas. String is an immutable data structure that stores text data in double quotes or single quotes. In this article, we will explore multiple approaches to concatenate all elements of a list into a single string using different Python methods. Using join() Method The join() method is a string method in Python that takes an iterable (list, tuple, etc.) and ...

Read More

Python program to compute arithmetic operation from String

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 697 Views

Arithmetic operations are mathematical calculations performed on numeric data types. Python supports several arithmetic operators that can be computed from string expressions. Addition (+) Subtraction (−) Multiplication (*) Division (/) Floor Division (//) Modulo (%) Exponentiation (**) There are several ways to compute arithmetic operations from strings. Let's explore different approaches with their advantages and limitations. Using the eval() Function The eval() function evaluates a string expression and returns the result. This is the simplest approach but should be used cautiously due to security risks. Example The eval() function directly evaluates the ...

Read More

Python program to check whether the values of a dictionary are in same order as in a list

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 257 Views

Python dictionaries store data as key-value pairs where keys are unique but values can be duplicated. Sometimes we need to check whether dictionary values appear in the same order as elements in a list. Python provides several approaches to accomplish this comparison efficiently. Using zip() with List Comprehension The zip() function pairs corresponding elements from multiple iterables, while list comprehension provides a concise way to create lists. Combined with all(), we can compare elements position by position ? Example def check_order(list_values, dict_values): return all(list_val == dict_val for list_val, dict_val in zip(list_values, ...

Read More
Showing 741–750 of 21,090 articles
« Prev 1 73 74 75 76 77 2109 Next »
Advertisements