Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Python Articles
Page 115 of 855
Flask form submission without Page Reload
Form submission is a crucial part of web applications, but traditional form submissions require page reloads, which can feel slow and disrupt user experience. Flask, combined with AJAX, allows you to submit forms asynchronously without page reloads, creating a smoother and more responsive application. Basic Flask Setup Let's start with a basic Flask application structure ? from flask import Flask, render_template, request, jsonify app = Flask(__name__) @app.route('/') def home(): return render_template('index.html') if __name__ == '__main__': app.run(debug=True) Creating the Flask Backend Here's the ...
Read MoreGet latest Government job information using Python
Government jobs offer stability, good benefits, and secure career prospects. Finding the latest job notifications can be time-consuming when done manually. This article demonstrates how to automate the process of collecting government job information using Python web scraping techniques. Required Libraries We need two essential Python packages for web scraping ? pip install requests beautifulsoup4 Import the required libraries in your Python script ? import requests from bs4 import BeautifulSoup Web Scraping Algorithm The process involves these key steps ? Target identification − Find the government job ...
Read MoreGet last n records of a Pandas DataFrame
When working with large datasets in Pandas, you often need to examine the most recent entries. The tail() method provides an efficient way to retrieve the last n records from a DataFrame. Syntax DataFrame.tail(n=5) Parameters: n − Number of rows to return from the end (default is 5) Creating a Sample DataFrame Let's create a DataFrame to demonstrate the tail() method ? import pandas as pd data = {'Name': ['John', 'Mark', 'Alice', 'Julie', 'Lisa', 'David'], 'Age': [23, 34, 45, 19, ...
Read MoreHow to Run Two Async Functions Forever in Python
Async functions, also known as coroutines, are functions that can be paused and resumed during their execution. In Python, the asyncio module provides a powerful framework for writing concurrent code using coroutines. In this article, we will explore how to run two async functions forever using different approaches in Python. Understanding Async Functions Async functions allow for concurrent execution of code without blocking the main thread, enabling efficient utilization of system resources. To define an async function in Python, we use the async keyword before the def statement. Within the async function, we can use the await keyword ...
Read MoreGet information about YouTube Channel using Python
YouTube, the world's largest video-sharing platform, hosts millions of channels with diverse content. Using Python and the YouTube Data API, we can programmatically retrieve detailed information about any YouTube channel, including subscriber count, view statistics, and video metrics. Installation First, install the Google API client library ? pip install --upgrade google-api-python-client Getting YouTube API Key To access YouTube data, you need an API key from Google Cloud Console ? Navigate to https://console.cloud.google.com/ to access the Google Cloud Console Create a new project or select an existing one Click "Navigation menu" → ...
Read MoreGet Indian Railways Station code Using Python
Web scraping is one of the many powerful uses for Python. In this article, we'll discover how to extract Indian Railways station codes using Python. Each Indian railway station has a unique identification code used for ticket reservations, train schedules, and other railway information. Installation First, we need to install the required libraries. Requests is used for sending HTTP requests, while Beautiful Soup is used for parsing HTML content. To install the required packages, open your terminal and run − pip install requests pip install beautifulsoup4 Algorithm Define a function get_html ...
Read MoreHow to Return Custom JSON in Django REST Framework
Django REST Framework is a powerful toolkit for building APIs in Django. It provides features and functionalities to handle HTTP requests and responses in Python. Django REST Framework uses Serializers and Response classes to return custom JSON data. In this article, we will explore different approaches to return custom JSON in Django REST Framework, along with examples. Using Serializers and Response Class Django REST Framework (DRF) uses serializers to convert complex data types, such as Django models, into JSON, XML, or other content types that can be easily rendered into HTTP responses. To return custom JSON, you can ...
Read MoreGet index in the list of objects by attribute in Python
Lists are a common data structure in Python for storing a collection of objects. Sometimes you need to find the index of a specific item in the list based on an attribute value. Python provides several efficient methods for getting the index in a list of objects by attribute. Syntax To find the index in a list of objects by attribute, use this syntax − index = next((i for i, obj in enumerate(my_list) if obj.attribute == desired_value), None) The next() method returns the first index where the object's attribute matches the desired value. If ...
Read MoreGet Flight Status using Python
Flight status refers to the current condition of a flight, indicating whether it is on schedule, delayed, or cancelled. Python provides powerful tools to extract flight information from airline websites using web scraping techniques with BeautifulSoup and requests libraries. Installation Before starting, ensure Python and the required libraries are installed on your system − pip install requests pip install beautifulsoup4 Algorithm Overview The flight status retrieval process follows these key steps − Import necessary libraries: requests, BeautifulSoup, and datetime Define the get_flight_details() function to construct URL and fetch HTML data Parse ...
Read MoreGet first n records of a Pandas DataFrame
Working with large datasets in Pandas can often be a daunting task, especially when it comes to retrieving the first few records of a dataset. In this article, we will explore the various ways to get the first n records of a Pandas DataFrame. Installation and Setup We must make sure that Pandas is installed on our system before moving further with the implementation ? pip install pandas Once installed, we can create a DataFrame or load a CSV and then retrieve the first N records. Methods to Get First n Records ...
Read More