Found 26504 Articles for Server Side Programming

Python Script to create random jokes using pyjokes

Mrudgandha Kulkarni
Updated on 11-Aug-2023 15:03:26

1K+ Views

Are you looking to add some humor to your Python scripts or applications? Whether you're building a chatbot, developing a command-line tool, or simply want to entertain yourself with a random joke, the pyjokes library is here to help. With pyjokes, you can effortlessly generate jokes in various categories and customize them to suit your preferences. In this blog post, we will explore how to use the pyjokes library to create random jokes in Python. We'll cover the installation process, generating jokes from different categories, customizing the jokes, displaying them in console applications or web pages, and handling any potential ... Read More

Total numbers with no repeated digits in a range

Vaishnavi Tripathi
Updated on 16-Aug-2023 10:38:47

3K+ Views

In this article, we will discuss different approaches to calculate the number of positive integers which have no repeated digits between a given range Low to high. The first approach is a brute force approach which iterates over all the numbers in the range and check if they contain repeated digits. In our second approach, we calculated the desired count using prefix array while in our last approach we used the concept of memorization in dynamic programming to get the desired result. Problem Statement: We are given two numbers low and high and we have to find the count of ... Read More

Tomohiko Sakamoto’s Algorithm- Finding the day of the week

Vaishnavi Tripathi
Updated on 16-Aug-2023 10:32:42

563 Views

In this article, we will discuss what is Tomohiko Sakamoto’s algorithm and how this algorithm is used to identify which day of the week does the given date occurs. There are multiple algorithms to know the day of the week but this algorithm is the most powerful one. This algorithm finds the day of the month on which the date occurs in least possible time and least space complexity. Problem statement − We are given a date as per Georgian calendar and our task is to find out which day of the week occurs on the given date using ... Read More

Recursive Practice Problems with Solutions

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

3K+ 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

548 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

140 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

604 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

6K+ 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

6K+ 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

12K+ 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

Advertisements