Found 10784 Articles for Python

How to take backups of MySQL databases using Python?

Tushar Sharma
Updated on 10-Jul-2023 18:31:34

3K+ Views

Safeguarding the integrity and recoverability of your MySQL database is of paramount importance to mitigate the risks associated with data loss and corruption. Python, a versatile programming language, offers a myriad of libraries and techniques for seamless interaction with MySQL databases and accomplishing efficient backup procedures. This article delves into three distinct methodologies for creating MySQL database backups using Python, encompassing the utilization of the subprocess module, integration of the mysqldump command with the pymysql library, and leveraging the robust capabilities of the MySQL Connector/Python library. Through practical examples, we will delve into the intricacies of these techniques. Method 1: ... Read More

{{ form.as_ul }} – Render Django Forms as list

Tushar Sharma
Updated on 10-Jul-2023 18:08:07

145 Views

Django has revolutionized web engineering, making it accessible and streamlined for developers globally. Its notable characteristic is the robust form manipulation system, which simplifies the development of web forms while also facilitating their verification and handling with ease. Concentrating on displaying these forms as HTML lists offers users a multitude of perks, such as advanced styling possibilities due to easy customization capabilities as well as augmented responsiveness and amplified accessibility. This composition plunges into the nuances of effectively displaying Django forms as lists by illuminating their numerous boons, delineating straightforward steps for implementation, and offering best practices for the ultimate ... Read More

{{ form.as_table }} – Render Django Forms as table

Tushar Sharma
Updated on 10-Jul-2023 18:01:57

862 Views

In the arena of web development, Django has emerged as a famous, open−source, and high−stage Python internet framework that encourages fast improvement and easy, pragmatic design. Django boasts a robust form of coping with devices, which allows developers to create, validate, and technique paperwork effortlessly. One essential component of Django's shape dealing with devices is its potential to render forms as HTML tables. In this post, we will go through the procedure of rendering Django forms as tables, which include the blessings, how to gain this, and a few exceptional practices to observe. By the end of this post, you ... Read More

How to Replace Values in Columns Based on Condition in Pandas

Rohan Singh
Updated on 10-Jul-2023 14:21:50

6K+ Views

In Python, we can replace values in Column based on conditions in Pandas with the help of various inbuilt functions like loc, where and mask, apply and lambda, etc. Pandas is a Python library that is used for data manipulation and work with structured data. In this article, we will replace values in columns based on conditions in Pandas. Method 1: Using loc The loc function is used to access a group of rows and columns in a DataFrame. We can use this function to replace values in a column based on some condition. Syntax df.loc[row_labels, column_labels] The loc ... Read More

Faulty calculator using Python

Rohan Singh
Updated on 10-Jul-2023 14:13:42

145 Views

A faulty calculator in Python is a calculator that gives incorrect results for certain calculations. In Python, we can create our own calculator and use it for doing mathematical calculations. If we want to create a faulty calculator we need to create or introduce errors in the functions that perform the calculations. In this article, we will create a faulty calculator using Python. Creating a faulty Calculator Creating a faulty calculator is easy as we need to just introduce some incorrect calculations in the normal calculator in the code to give an incorrect result which converts it into a ... Read More

How to replace a word in Excel using Python?

Rohan Singh
Updated on 10-Jul-2023 14:17:35

1K+ Views

In Python, we can replace a word in Excel with another word using a third-party Python library called openpyxl. Microsoft Excel is a useful tool that is used for managing and analyzing data. Using Python we can automate some of the Excel data management tasks. In this article, we will understand how we can replace a word in Excel using Python. Installing openpyxl Before implementing the program to replace Word in Excel we need to install the openpyxl library in our system using the Python package manager. To install openpyxl type the following command on your terminal or command ... Read More

Python Program to Find the Number of Unique Words in Text File

Saba Hilal
Updated on 10-Jul-2023 17:07:13

2K+ Views

In this article, the given task is to find the number of unique words in a text file. In this Python article, using two different examples, the approaches to finding the unique words in a text file and their count are given. In the first example, given words from a text file are fetched, and then their unique set is made before counting these unique words. In example 2, first the list of words is created, then it is sorted. After this from this sorted list, the duplicates are removed and finally, the unique word left in the file ... Read More

Python program to find the frequency of the elements which are common in a list of strings

Saba Hilal
Updated on 10-Jul-2023 17:03:58

110 Views

In this Python article, the given task is to get the frequency of the elements which are common in a list of strings. Sometimes the list to be analyzed using Python is available in an Excel file. To get this list from Excel, a module called openpyxl is used. In this Python article, using three different examples, the ways of getting the frequency of the items which are repeated in a list of strings are given. In example 1, the frequency of the characters which are common in a list of strings is found. In the next two examples, ... Read More

Python Program to Find Sum of First and Last Digit

Saba Hilal
Updated on 10-Jul-2023 16:51:14

875 Views

In this article, the given task is to add the first and the last digit of an integer. Now the integer can be very small or it can be a big number. So, these programs will have two parts. First, we need to find how big the integer is and then get the first digit from it. The second part will be to get the last number from the given integer which can be done easily by dividing the number by ten and finding the remainder. In this Python article, using four different examples, the approaches to adding the first ... Read More

Python program to print positive numbers in a list

Saba Hilal
Updated on 10-Jul-2023 16:23:30

360 Views

In this article, the task is to print the positive numbers from a list of integers. Here, in this Python article, this task is done using the different methods in 4 different examples. Then these positive numbers are printed. In example 1, the positive numbers are picked and separated into another list. In the example 2, all the elements that are not positive are removed. In example 3, the sorted list is split up to zero and only positives are retained. In example 4, filter is used to select the positive numbers. Example 1 - Select only the positive numbers ... Read More

Advertisements