Found 27104 Articles for Server Side Programming

Recursive Practice Problems with Solutions

Vaishnavi Tripathi
Updated on 16-Aug-2023 10:22:31

1K+ Views

In this article, we will discuss a few recursive practice problems with their detailed solutions. Let us first understand what recursion is and how it works: Recursion − Recursion is a programming technique in which a function or method calls itself multiple times in order to solve a problem. The function breaks down the problem into smaller sub-problems and solves them until it reaches a base case. The base case is a stopping condition that makes sure that the function stops calling itself and returns a result in finite time. Recursion is a powerful technique for solving complex ... Read More

Swap every two bits in bytes

Vaishnavi Tripathi
Updated on 16-Aug-2023 10:16:20

194 Views

In this article, we will discuss the code solution to swap every alternate bit in a given number and return the resultant number. We will use the concept of bit manipulation in order to solve the problem in constant time without using any loops. Problem statement − We are given a number n, we have to swap the pair of bits that are adjacent to each other. In other words, we have to swap every odd placed bit with its adjacent even placed bit. Constrain: While solving the problem, we have to keep In mind that we cannot use ... Read More

Sum of Series (n^2-1^2) + 2(n^2-2^2) +….n(n^2-n^2)

Vaishnavi Tripathi
Updated on 16-Aug-2023 10:14:31

51 Views

In this article, we will study different approaches to calculate the sum of the series- (n^2 - 1^2) + 2(n^2 - 2^2) + …. n(n^2 - n^2). In the first approach, we will calculate the series sum one by one for each i in the range 1 to n and keep adding it to the final sum. In the second approach, we will derive a mathematical formula to calculate the sum of the given series which will result in the reduced time complexity of the program from O(n) to O(1). Problem statement − We are given a number “n “and ... Read More

Handling PostgreSQL BLOB data in Python

Jaisshree
Updated on 10-Aug-2023 17:20:36

329 Views

PostgreSQL is an open-source, object-relational database management system that offers diverse data types to save data.The BLOB (Binary large object) data kind is one instance of this. It is used to keep large binary records, such as audio, video, and photograph files. We should first set up the psycopg2 package, which offers a Python interface for PostgreSQL, so as to work with PostgreSQL in Python. The pip package manager is used to install it. Syntax pip install psycopg2-binary After the installation of the psycopg2 library, we need to connect to our PostgreSQL database with Python. The ... Read More

Get a list of a Particular Column Values of a Pandas Dataframe

Jaisshree
Updated on 10-Aug-2023 17:11:42

4K+ Views

Pandas is a Python Library that is used to explore and clean the messy datasets, and make the data suitable for extracting necessary and valuable insights. Dataframe in Pandas is a two-dimensional data structure which is very much similar to spreadsheets, SQL tables, and Excel Datasheets. We can use various methods to extract the particular column values. Using '.values.tolist()' method Using '.loc[]' method Using '.iloc[]' method Using 'get()' function ... Read More

Generating Random Integers in Pandas Dataframe

Jaisshree
Updated on 10-Aug-2023 17:03:56

3K+ Views

Generating random integers in a DataFrame using Python's Pandas library is an instrumental data analysis and manipulation technique. By developing and inserting random integers into a DataFrame, you open up a world of possibilities for various applications. This functionality proves particularly valuable in tasks like data simulation, algorithm testing, and generating synthetic datasets. Familiarizing yourself with this feature will undoubtedly enhance the flexibility and versatility of your data analysis workflows. Method 1: Using the randint() function from NumPy The randint() function found in the NumPy library is commonly utilized to generate random integers within a designated range, in ... Read More

Python script that is executed every 5 minutes

Mrudgandha Kulkarni
Updated on 10-Aug-2023 16:57:57

7K+ Views

Automation and task scheduling play a crucial role in streamlining repetitive tasks in software development. Imagine having a Python script that needs to be executed every 5 minutes, such as fetching data from an API, performing data processing, or sending regular updates. Manually running the script at such frequent intervals can be time-consuming and prone to errors. That's where task scheduling comes in. In this blog post, we will explore how to schedule the execution of a Python script every 5 minutes, ensuring that it runs automatically without requiring manual intervention. We will discuss different approaches and libraries that can ... Read More

Python requests - POST request with headers and body

Mrudgandha Kulkarni
Updated on 10-Aug-2023 16:56:36

8K+ Views

Python's requests library is a powerful tool for making HTTP requests in a simple and efficient manner. It provides an easy-to-use interface for sending GET, POST, and other types of requests to web servers. When it comes to making a POST request, it's often necessary to include headers and a request body, which contain additional information and data for the server to process. In this article, we will explore how to use the requests library to make a POST request with headers and a body. We will cover the fundamental concepts of headers and request bodies, demonstrate their usage in ... Read More

Python Regex Cheat Sheet

Mrudgandha Kulkarni
Updated on 10-Aug-2023 16:55:15

323 Views

Regular expressions, commonly known as regex, are powerful tools for pattern matching and text manipulation in Python programming. They allow you to search, extract, and modify text based on specific patterns, making them essential for tasks such as data validation, string manipulation, and text processing. However, working with regular expressions can be challenging, especially for beginners or those who don't use them frequently. Remembering the syntax and understanding the various metacharacters and rules can be daunting. To make your regex journey smoother, we have created a comprehensive Python Regex Cheat Sheet. This cheat sheet serves as a handy reference guide, ... Read More

Generating Basic Discrete Time Signals

Jaisshree
Updated on 10-Aug-2023 16:48:05

739 Views

Discrete time signals serve extensively in signal processing to analyze and interpret digital signals. Creating simple discrete time signals helps us to replicate and comprehend numerous signal kinds such as unit step, impulse, ramp, and sinusoidal signals. Let us first define the four main discrete-time signals that are employed in signal analysis. Unit Step Signal The unit step signal is a basic and extensively used signal in signal analysis. It represents 0 for negative time indices and 1 for positive time indices. Impulse Signal These signals are also termed as Dirac delta function, ... Read More

Advertisements