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
Articles by Atharva Shah
Page 3 of 6
How to add Site Header, Site Title, Index Title in a Django Project?
Django templates use a powerful template system that allows you to create reusable layouts with dynamic content. Adding a site header, site title, and index title helps users navigate and understand your website's purpose. This tutorial shows how to implement these elements using Django's template inheritance system. Template Structure Overview Django templates use template blocks to define sections that can be overridden in child templates. The basic approach involves creating a base template with placeholder blocks, then extending it in specific pages. Step 1: Create Base Template First, create a base template that defines the overall ...
Read MoreCreate list of Tuples using for Loop using Python
Python's key data structures are lists and tuples. Tuples are immutable collections where elements cannot be changed once set, while lists can be modified after initialization. When dealing with data that needs to be grouped together, a for loop is commonly used to create lists of tuples. This tutorial demonstrates creating a list of tuples using a for loop, simplifying repetitive data organization tasks. Syntax for variable in iterable: # loop code Basic Operations on Tuples Creating and Accessing Tuples # Initializing tuples my_tuple = (1, 2, "Hello", ...
Read MoreHow to Create a Dictionary Of Tuples in Python
A dictionary of tuples in Python combines the key-value structure of dictionaries with the immutable, ordered nature of tuples. This creates an efficient way to store multiple related values for each key, such as student information, product details, or coordinates. Syntax The basic syntax for creating a dictionary of tuples is ? dictionary_name = { key1: (value1_1, value1_2, ...), key2: (value2_1, value2_2, ...), key3: (value3_1, value3_2, ...) } Basic Example Let's create a dictionary storing student names and their test scores ...
Read MorePython - Create a string made of the first and last two characters from a given string
This tutorial demonstrates how to create a new string using the first and last two characters from a given string through string slicing. This technique is useful for data processing, text formatting, and extracting key information from strings. Algorithm Start with the given string Use slicing [:2] to extract the first two characters Use negative slicing [-2:] to extract the last two characters Concatenate both parts to form the new string Basic Example Here's the simple approach to create a new string ...
Read MoreHow to Create a List of Tuples in Python?
In Python, creating a list of tuples is a flexible approach for storing related data items together. Tuples are immutable, ordered collections that are perfect for grouping related information like coordinates, records, or key-value pairs. Basic List of Tuples Creation The simplest way to create a list of tuples is by directly defining them ? # Create a list of tuples containing student records student_records = [ ("Alice Johnson", 25, "A"), ("Bob Smith", 21, "B"), ("Charlie Brown", 23, "A"), ] # Iterate through ...
Read MoreCreate a box in Python GTK+ 3
GTK+ 3 is a sophisticated graphical user interface library for creating cross-platform desktop applications. It provides an extensive range of tools and widgets for building interactive and appealing GUIs. Let's explore how to create and use box layouts in GTK+ 3 to organize widgets within a window. Setup and Installation For Windows users, install the Windows Subsystem for Linux (WSL) to use Linux commands and PyGObject in Windows environments. This simplifies access to libraries and GObject Introspection bindings. Install the required packages: pip install PyGObject sudo apt install libcairo2-dev python3-gi gir1.2-gtk-3.0 gcc libgirepository1.0-dev gobject-introspection pkg-config ...
Read MoreDifferences and Applications of List, Tuple, Set and Dictionary in Python
Python provides four fundamental built-in data structures: lists, tuples, sets, and dictionaries. Each has unique characteristics that make them suitable for different programming scenarios. Understanding their differences helps you choose the right data structure for your specific needs. List A list is an ordered, mutable collection enclosed in square brackets []. Lists allow duplicate elements and support indexing, slicing, and modification operations. Key Features Mutable: You can add, remove, or modify elements after creation Ordered: Elements maintain their insertion order Duplicates allowed: Same values can appear multiple times Indexing and slicing: Access elements by position ...
Read MoreFlask 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 More