Articles on Trending Technologies

Technical articles with clear explanations and examples

Modelling the Carnot Cycle in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 2K+ Views

The Carnot cycle is the most fundamental gas power cycle that serves as a benchmark for all engine cycles. Every engine cycle efficiency is validated against the Carnot cycle's theoretical maximum efficiency. It comprises four processes: two reversible adiabatic processes and two isothermal processes. ...

Read More

Python Program to sort a tuple of custom objects by properties

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

Python allows us to create custom objects using classes to represent complex data structures. When we have a tuple containing these custom objects, we often need to sort them by specific properties like name, age, or other attributes. A custom object is an instance of a user-defined class that encapsulates data and behavior specific to our needs. Here's how we define a simple class ? class Person: def __init__(self, name, age): self.name = name self.age = age ...

Read More

Python Program to Replace Elements in a Tuple

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

In this article, you will learn how to replace elements in a tuple using Python. Since tuples are immutable, we cannot directly modify their elements. Instead, we need to use specific techniques to create new tuples with updated values. Before exploring the replacement methods, let's understand what tuples are in Python. What is a Tuple in Python? A tuple is one of Python's four built-in data types for storing collections. The other three are list, set, and dictionary, each with unique features and applications. Tuples are ordered and immutable collections. We create tuples by placing elements ...

Read More

Python Program to search an element in a tuple

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

In Python, searching for elements within a data structure is a common task and different types of data structures should aim to provide efficient methods for searching. The problem of searching involves finding a specific element within a container and returning a value indicating whether it was found or not. One data structure that can be used for this task is a tuple, which stores a collection of different types of data in a single variable. These items can be accessed by their index and Python offers various methods to work with them. Tuples are immutable, meaning that once ...

Read More

Python Program to check if the tuple is empty

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

In Python, checking if a tuple is empty is a common operation needed to determine what actions to take in a program. A tuple is an ordered collection of items that is immutable, meaning its contents cannot be changed after creation. A tuple is considered empty if it contains zero elements. Python provides several methods to check for empty tuples, each with different advantages. What is a Tuple? A tuple in Python is defined using parentheses and can store heterogeneous data ? # Creating tuples non_empty_tuple = (1, 'a', 3.7) empty_tuple = () print("Non-empty ...

Read More

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

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 604 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
Showing 1701–1710 of 61,297 articles
« Prev 1 169 170 171 172 173 6130 Next »
Advertisements