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
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
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
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
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
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
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
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP