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
Programming Articles
Page 113 of 2547
How to install Python in Windows?
Python is a widely used high-level programming language. To write and execute code in Python, we first need to install Python on our system. Installing Python on Windows takes a series of few easy steps. This guide will walk you through the complete process. Step 1 − Select Version of Python to Install Python has various versions available with differences between the syntax and working of different versions of the language. We need to choose the version which we want to use or need. Python 3.x is the current version and recommended for new projects. Python ...
Read MorePython Pandas – How to use Pandas DataFrame tail( ) function
The Pandas DataFrame tail() function returns the last n rows of a DataFrame. This is particularly useful when combined with filtering operations to examine the bottom portion of your filtered data. Syntax DataFrame.tail(n=5) Parameters: n (int, optional): Number of rows to select. Default is 5. Creating Sample Data Let's create a sample dataset to demonstrate the tail() function ? import pandas as pd # Create sample products data data = { 'id': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ...
Read MorePython Pandas – How to use Pandas DataFrame Property: shape
The shape property in Pandas DataFrame returns a tuple containing the number of rows and columns. It's essential for understanding your dataset dimensions before performing data analysis operations. DataFrame.shape Property The shape property returns (rows, columns) as a tuple. You can access individual values using indexing ? # Basic syntax df.shape # Returns (rows, columns) df.shape[0] # Number of rows df.shape[1] # Number of columns Creating Sample Data Let's create a sample products dataset to demonstrate the shape ...
Read MoreMake three numbers Zero in Python
Let us suppose we have three numbers. The task is to count the total number of optimal steps to make all these numbers zero by repeatedly removing 1 from any two numbers at a time. Problem Statement Given three numbers, find the minimum number of steps to make all three numbers zero, where in each step you can subtract 1 from any two numbers. Example Input: a = 4 b = 4 c = 6 Output: 7 Step-by-step explanation: Initial state: (4, 4, 6) Step 1: Remove ...
Read MoreLargest Merge of Two Strings in Python
When merging two strings, we want to create the lexicographically largest possible result by choosing characters strategically. This problem involves comparing entire remaining substrings at each step to make optimal choices. Problem Understanding Given two strings a and b, we need to merge them by repeatedly choosing which string to take the next character from. The key rule is: always choose from the string whose remaining portion is lexicographically larger. Algorithm Steps Compare the remaining portions of both strings Take the first character from the lexicographically larger string Repeat until both strings are empty Append ...
Read MoreCopy list with random Pointer in Python
A Linked List with Random Pointers is a data structure where each node contains data, a next pointer, and an additional random pointer that can point to any node in the list. Creating a deep copy of such a list requires preserving both the structure and random pointer relationships. The challenge is to copy not just the values and next pointers, but also maintain the correct random pointer connections in the new list. Problem Example Consider a linked list where each node has a random pointer: 1 ...
Read MoreBreadth First Search on Matrix in Python
Breadth First Search (BFS) on a matrix finds the shortest path between two cells by exploring neighbors level by level. In a 2D matrix, each cell can move in four directions: left, right, up, and down. Matrix Cell Types In BFS matrix problems, cells are typically represented by different values ? 0 − Blocked cell (cannot move through) 1 − Open cell (can move through) 2 − Source cell (starting point) 3 − Destination cell (target point) BFS Algorithm for Matrix The algorithm uses a queue to explore cells level by level ? ...
Read MoreBalanced Binary Tree in Python
In a binary tree, each node contains two children, i.e left child and right child. Let us suppose we have a binary tree and we need to check if the tree is balanced or not. A Binary tree is said to be balanced if the difference of height of left subtree and right subtree is less than or equal to 1. Problem Examples Example 1 - Balanced Tree 1 2 ...
Read MorePython Pandas - Read data from a CSV file and print the 'product' column value that matches 'Car' for the first ten rows
When working with CSV data in Pandas, you often need to filter specific rows based on column values. This tutorial shows how to read a CSV file and filter rows where the 'product' column matches 'Car' from the first ten rows. We'll use the 'products.csv' file which contains 100 rows and 8 columns with product information. Sample Data Structure The products.csv file contains the following structure ? Rows: 100 Columns: 8 id product engine avgmileage price height_mm width_mm productionYear 1 2 ...
Read MoreHow can Tensorflow be used to compose layers using Python?
TensorFlow allows you to compose layers by creating custom models that inherit from tf.keras.Model. This approach enables you to build complex architectures like ResNet identity blocks by combining multiple layers into reusable components. Understanding Layer Composition Layer composition in TensorFlow involves creating custom models that encapsulate multiple layers. This is particularly useful for building residual networks where you need to combine convolutional layers, batch normalization, and skip connections into a single reusable block. Creating a ResNet Identity Block Here's how to compose layers by creating a ResNet identity block that combines multiple convolutional and batch normalization ...
Read More