Subtract Tuple of Tuples from a Tuple in Python

Sindhura Repala
Updated on 24-Apr-2025 18:54:40

560 Views

What is Python Tuple? A tuple in Python is an ordered collection of items that cannot be changed once, making it immutable. A tuple allows duplicate values and can hold elements of different data types, such as strings, numbers, other tuples, and more. This makes tuples useful for grouping related data while determining that the content remains fixed and unchanged. Subtracting Tuples from Tuples in Python To subtract a tuple of tuples from a tuple in Python, we can use a loop or comprehension to filter out elements. Since tuples are immutable and don't support direct subtraction, convert the main ... Read More

Use Multiple Tuple in Python

Sindhura Repala
Updated on 24-Apr-2025 18:52:18

1K+ Views

What is Python Tuple? A tuple in Python is an ordered collection of items that cannot be changed once defined, making it immutable. A tuple allows duplicate values and can hold elements of different data types, such as strings, numbers, other tuples, and more. This makes tuples useful for grouping related data while the content remains fixed and unchanged. Multiple Tuples in Python Multiple tuples organize complex information hierarchically, and these are useful for returning multiple values, iterating over grouped values. In Python, we can create multiple tuples by - ... Read More

Canonical Way to Check for Type in Python

Sindhura Repala
Updated on 24-Apr-2025 18:38:30

214 Views

A tuple in Python is an ordered collection of items that cannot be changed once, making it immutable. This allows duplicate values and can hold elements of different data types, such as strings, numbers, other tuples, and more. This makes tuples useful for grouping related data while determining the content remains fixed and unchanged. What is Canonical Way? In programming, "canonical" refers to the standard, widely accepted, or recommended way approach to accomplishing a task. It determines with best practices and this is favored by the community or official documentation. In Python, performing a task canonically means using the most ... Read More

Covariant Return Types in Java

Shriansh Kumar
Updated on 24-Apr-2025 18:32:02

11K+ Views

In Java, covariant return types allow an overriding method to return a subtype of the supertype. Here, the return type of the parent class is called the supertype, and the return type of the child class is known as the subtype, if and only if it is a subclass of the parent class's return type. Sounds confusing, right? Well! It is not as confusing as it sounds. Read the whole article to understand this concept. Java Covariant Return Types Covariant return type refers to the return type of an overriding method. It works only for non-primitive return types, such as Classes, Arrays, ... Read More

Downcasting in Java

Shriansh Kumar
Updated on 24-Apr-2025 18:22:54

451 Views

What is Downcasting? Typecasting an object of the parent class to an object of the child class is called Downcasting in Java. We need to tell the Java compiler to perform the conversion explicitly by creating an object of the child type using a reference of the parent type. It is the opposite of upcasting, where a subclass reference is converted into a superclass reference automatically by the compiler. Typecasting is a process in which one data type or object is converted into another. It works with primitive datatypes and reference types as well. In this article, we are going ... Read More

Interface Enhancements in Java 8

Shriansh Kumar
Updated on 24-Apr-2025 18:20:41

650 Views

Before the release of Java version 8, the interface consists of only abstract methods and variables that defines the behavior that a class could implement. While adding a new method to an interface, it required change in all the implementing classes. It was not convenient for a large application. To overcome this, Java 8 introduced default and static methods in interfaces. In Java, an Interface is a type of class that is defined using the keyword interface and has only method bodies without any implementations. To access its members within a class, we need to use the implements keyword while ... Read More

Compile and Run Java Program Using Command Prompt

Shriansh Kumar
Updated on 24-Apr-2025 18:17:52

19K+ Views

Command prompt is a command line interface that accepts text-based inputs or commands and performs tasks based on those command. Nowadays, there are various integrated development environments (IDEs) that are available to compile, build, and run Java programs within their environment. However, we can also compile and run Java programs using the Command Prompt. Compiling and Running Java Programs using CLI To compile and run Java programs outside the IDEs using the Command Prompt, we need to install the JDK and set its path in our system. To set up the development environment for Java on your local machine, we ... Read More

Differences Between While Loop and Do-While Loop in Java

Shriansh Kumar
Updated on 24-Apr-2025 18:17:00

8K+ Views

In Java, the do-while and while loops are used to repeat a block of code multiple times based on a condition. These loops help us to avoid writing the same code again and again. Both loops are used when we don't know exactly how many times the loop should run. In this article, we will understand the difference between the while loop and the do-while loop. The while Loop The while loop in java executes one or more statements after testing the loop continuation condition at the start of each iteration. Syntax The while loop follows the syntax given ... Read More

Regular Expression Back References in Python

Nikitasha Shrivastava
Updated on 24-Apr-2025 18:07:20

886 Views

Backreferences in regular expressions allow us to reuse a previously recorded group inside the same regex pattern. This ability is very useful when we want to match recurrent patterns in strings. What are Backreferences? A regular expression reference to a previously recorded group is called a backreference. When parentheses "()" are used in a regex pattern, a group is formed. Each group is assigned a number; the number for the first group is 1. We can refer to these recorded groups in our regex by using the backslash \ after the group number. Basic Syntax Here is the basic ... Read More

Setup VIM Autoindentation for Editing Python Files

Niharikaa Aitam
Updated on 24-Apr-2025 17:04:01

2K+ Views

When programming in Python, proper indentation is essential as the language uses it to define the structure of the code such as loops, functions and conditionals. Even minor mistakes in indentation can lead to errors or unexpected behavior by making it critical to maintain consistency. Vim Editor Vim is a highly efficient text editor which offers flexible configuration options to automate indentation by ensuring that our code is properly formatted according to Python's standards. By adjusting Vim's settings we can configure it to handle indentation in Python files with ease. This includes converting tabs to spaces, setting the appropriate indentation ... Read More

Advertisements