In Python, inheritance is the capability of one class to derive or inherit the properties from another class. The class that derives properties is called the derived class or child class, and the class from which the properties are being derived is called the base class or parent class. In other words, inheritance refers to defining a new class with little or no modification to an existing class. Following is the syntax of the inheritance - class A: #class A (base class) pass class ... Read More
In Python, strings can be defined using single quotes ('), double quotes ("), or triple quotes (''' or """). For example, 'Hello' is a valid string. There are different types of quotes in Python. Each quotation is used in different scenarios as per the requirement. The following are the different types of quotations that we can use in the Python programming language. Single quotes Double quotes ... Read More
In this problem, we are given an array of integers. In the given array, each element occurs two times except one element, which occurs only once. We have to find the number that appears only once. In this article, we are going to learn how we can find the number that appears once, and all other numbers appear twice in Java. Scenario 1 All other numbers except 4 occur twice, so 4 is the only number that appears only once. Input: [ 1, 2, 3, 3, 2, 4, 1, 5, 5] Output: 4 Scenario 2 All other numbers except ... Read More
Rotating an array means shifting the elements of an array in a specific direction while maintaining their relative order. For example, if the array {6, 12, 18, 24, 30} is rotating it left once will result in {12, 18, 24, 30, 6}. In this article, we are given an array and need to shift all elements one step to the left, with the first element moving to the last position. Example Here is an example of left rotation of elements in array by one place. Input: array = {5, 10, 15, 20, 25} Output: array = {10, 15, ... Read More
In Python, the dict.items() and dict.iteritems() methods are used to return a dictionary. The only difference is that the dict.items() returns the keys and value pairs in the form of a list of tuple pairs, whereas the dict.iteritems() returns an iterator over the dictionary’s (key, value) tuple pairs. The dict.items() and dict.iteritems() functions are present in Python 2.x versions. The dict.iteritems() function is omitted from the Python 3.x version. Example - 'dict.items()' in Python 2.x version Following is an execution of the dict.items() in Python 2.x version - my_dict={1:'one', 2:'two', 3:'three', 4:'four'} print(my_dict.items()) Output Following is the output ... Read More
Complex numbers are numbers that have both real and imaginary components in the structure, a+bi. You can find the square root of complex numbers in Python using the cmath module. This module in Python is exclusively used to deal with complex numbers.Square Root of Complex Numbers Using cmath.sqrt() The cmath.sqrt() function is a part of Python's cmath module, that takes a number which is an integer or float (real or complex) and returns the complex square root of x. Below are some examples of scenarios where the function can be used - Example - Basic Complex Number In the below ... Read More
A convex hull is the smallest convex polygon with maximum area and minimum perimeter that encloses all the given points in a 2D plane. In this article, we will learn how to write C++ program to implement Graham Scan Algorithm to find convex hull. The objective of this problem is to take a set of x and y coordinates of a 2d plane as input, and display coordinate point from the set which are part of convex hull. // Input Set of points: {0, 0}, {1, 1}, {2, 2}, {2, 0}, {1, 2}, {0, 2} // Output Boundary ... Read More
A convex hull is the smallest convex polygon with maximum area and minimum perimeter that encloses all the given points in a 2D plane. In this article, we will learn how to write C++ program to implement Jarvis March Algorithm to find a convex hull. The objective of this problem is to take a set of x and y coordinates of a 2d plane as input, and display coordinate point from the set which are part of convex hull. // Input Set of points: {0, 0}, {1, 1}, {2, 2}, {2, 0}, {1, 2}, {0, 2} // Output ... Read More
In Python, when working with files and directories, we may often need to get a list of subdirectories within a specific location, especially the current working directory. In this article, we are going to use the different methods available in Python to get a list of all subdirectories in the current directory. Using os Module While working with files, one of the most widely used approaches is using os module. This module provides a way to interact with the operating system to perform tasks such as navigating directories, reading file structures, and more. In this module, we have a ... Read More
In Java, a GridLayout puts all the components in a rectangular grid and is divided into equal-sized rectangles, and each component is placed inside a rectangle whereas GridBagLayout is a flexible layout manager that aligns the components vertically and horizontally without requiring that the components be of the same size. Java GridLayout A GridLayout arranges the components in a rectangular grid. It arranges components in the cells, and each cell has the same size. Components are placed in columns and rows. GridLayout(int rows, int columns) takes two parameters that are a column and a row. Syntax The following is the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP