Harshit Sachan

Harshit Sachan

25 Articles Published

Articles by Harshit Sachan

Page 2 of 3

Python Program to add element to first and last position of linked list

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 603 Views

In Python, a linked list is a linear data structure that consists of a chain of nodes, where each node contains a value and a reference to the next node in the chain. In this article, we will be discussing how to add an element to the first and last position of a linked list in Python. Linked List in Python A linked list is a referential data structure that holds a group of elements. It is similar to an array but while data is stored in contiguous memory locations in an array, in a linked list ...

Read More

Python Program to remove duplicate elements from a dictionary

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 5K+ Views

In this article, we will discuss how to remove duplicate elements from a dictionary in Python. A dictionary stores key-value pairs where keys must be unique, but values can be duplicated. Sometimes we need to clean up data by keeping only unique values. We can declare a dictionary in the following way − sample_dict = {"brand": "Ford", "model": "Mustang", "year": 1964} print(sample_dict) {'brand': 'Ford', 'model': 'Mustang', 'year': 1964} A dictionary can contain duplicate values for different keys, but we might want to have only unique values. Let's explore two methods to remove ...

Read More

Python program to print the keys and values of the tuple

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 2K+ Views

In Python, tuples are a useful data type for storing a collection of items. Sometimes, it may be necessary to print the keys and values of a tuple in order to understand or debug your code. In this article, we will discuss how to print the keys and values of a tuple in Python. We will go over the syntax for accessing these elements and provide examples of how to do so. First, let's understand what tuples are and what we mean by keys and values in the context of tuples. What is a Python Tuple? ...

Read More

Python program to get first and last elements from a tuple

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 33K+ Views

Tuples are an important data type in Python that store multiple elements in a fixed order. In this article, we'll learn different methods to access the first and last elements from a tuple efficiently. What is a Tuple in Python? A tuple is an ordered collection of items that is immutable (unchangeable). Tuples are defined using round brackets and can store elements of different data types. Example fruits = ("apple", "banana", "cherry") print(fruits) print(type(fruits)) ('apple', 'banana', 'cherry') Method 1: Using Index Notation The most straightforward way to access ...

Read More

Python Program to compare elements in two dictionaries

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 3K+ Views

Dictionaries are a powerful data type in Python that allow you to store data as key-value pairs. In this article, we will discuss how to compare elements in two dictionaries using three different approaches: equality operator, loops, and list comprehension. Understanding Dictionaries In Python, a dictionary is created by placing key-value pairs within curly brackets { }, separated by commas. Values can be of any data type and can be duplicated, whereas keys must be unique and immutable. # Creating dictionaries dict1 = {"brand": "Ford", "model": "Mustang", "year": 1964} dict2 = {"brand": "Toyota", "model": "Camry", "year": ...

Read More

Python program to print even numbers in a list

Harshit Sachan
Harshit Sachan
Updated on 25-Mar-2026 13K+ Views

Python lists are fundamental data structures that store collections of items. Finding even numbers in a list is a common programming task with multiple efficient approaches. A number is even if it divides by 2 with no remainder. We will explore several methods to print even numbers from a list, each with different advantages ? Using Modulo Operator The modulo operator (%) returns the remainder when dividing two numbers. For even numbers, x % 2 == 0 will be true. Example def print_evens(numbers): for num in numbers: ...

Read More

Python program to print even length words in a string

Harshit Sachan
Harshit Sachan
Updated on 25-Mar-2026 6K+ Views

In Python, you can find and print all words in a string that have even length (divisible by 2). This is useful for text processing tasks where you need to filter words based on their character count. For example, in the string "A big cube was found inside the box", the words "cube" (length 4) and "inside" (length 6) have even lengths. Basic Approach The simplest method involves splitting the string into words and checking each word's length ? def print_even_length_words(text): # Split the string into individual words ...

Read More

How to transform background image using CSS3

Harshit Sachan
Harshit Sachan
Updated on 15-Mar-2026 2K+ Views

The CSS transform property allows you to apply 2D and 3D transformations to elements, including background images. You can rotate, scale, translate, and skew elements to create visual effects without affecting the document flow. Syntax selector { transform: none | transform-function | initial | inherit; } Transform Functions FunctionDescription rotate(angle)Rotates element by specified angle scale(x, y)Scales element along X and Y axes translate(x, y)Moves element along X and Y axes skew(x-angle, y-angle)Skews element along X and Y axes Example: Rotating Background Image The following example demonstrates ...

Read More

How to create an accordion hover effect with box-shadows in CSS

Harshit Sachan
Harshit Sachan
Updated on 15-Mar-2026 729 Views

An accordion hover effect with box-shadows in CSS creates an interactive element that expands content when hovered over, while adding visual depth through shadows. This effect combines CSS transitions, hover states, and the box-shadow property to create smooth, engaging user interactions. Syntax selector { box-shadow: x-offset y-offset blur-radius spread-radius color; } selector:hover { box-shadow: x-offset y-offset blur-radius spread-radius color; } Box-Shadow Property Values PropertyDescription x-offsetHorizontal shadow position (positive = right, negative = left) y-offsetVertical shadow position (positive = down, negative = up) blur-radiusOptional. Controls ...

Read More

How to create a Non-Rectangular Header using HTML & CSS

Harshit Sachan
Harshit Sachan
Updated on 15-Mar-2026 596 Views

A non-rectangular header adds visual appeal to web pages by breaking away from traditional rectangular layouts. Using CSS's clip-path property, we can create custom shapes for headers that make our designs stand out. Syntax header { clip-path: polygon(coordinates); } Basic Approach To create a non-rectangular header, we use the following steps − Create a element with content Apply the clip-path CSS property with polygon coordinates Position content appropriately within the clipped area Example 1: Wavy Bottom Header Here's how to create a header with a ...

Read More
Showing 11–20 of 25 articles
Advertisements