Declare an Interface in C++

Revathi Satya Kondra
Updated on 17-Apr-2025 17:58:16

585 Views

The C++ interfaces are implemented using abstract classes and these abstract classes should not be confused with data abstraction which is a concept of keeping implementation details separate from associated data. A class is made abstract by declaring at least one of its functions as a pure virtual function. A pure virtual function is specified by placing "= 0" in its declaration as follows : class Box { public: // pure virtual function virtual double getVolume() = 0; private: ... Read More

Standard Size of Character 'a' in C/C++ on Linux

Revathi Satya Kondra
Updated on 17-Apr-2025 17:56:51

5K+ Views

In C/C++, every character including 'a' is stored using a specific size in memory. Most of the systems including Linux, the size of a character is 1 byte. This means that any character (like a) can occupy 1 byte(8 bits of memory). To determine how much memory is used by the character 'a', we can use the sizeof() operator. So, it returns the size in bytes of a variable or data type. Following are the list of different ways to check the Standard Size in C/C++. Using sizeof with character literal ... Read More

Run Python Files Together

Niharikaa Aitam
Updated on 17-Apr-2025 17:56:24

60K+ Views

In Python, it is often necessary to execute another file. This is common in cases such as running helper scripts, triggering workflows, or executing test cases. Python provides several ways to execute one file using another. Depending on the requirement, whether we want to reuse functions, execute a file directly, or run it as a subprocess. Let us look at these solutions one by one - Understanding Python Script Execution Before proceeding with how to run one Python file from another, it's important to understand how Python scripts are executed. When we run a Python file using python myscript.py ... Read More

How Does Underscore "_" Work in Python Files

Niharikaa Aitam
Updated on 17-Apr-2025 17:44:02

692 Views

In Python, the underscore (_) is a special character with different meanings based on how and where it is used. It plays a significant role in readability, naming conventions, and interpreter behavior. In this article, we will discuss different scenarios of using the Underscore(_) in Python. Single Underscore _ in Python The single underscore (_) is used in Python for special purposes, which depend on the context. These are one of the most versatile and commonly seen symbols in clean and Pythonic code. Use Cases of _ (Single Underscore) The single underscore(_) can be used in different use cases. Let's ... Read More

List Files in Python Directory

Niharikaa Aitam
Updated on 17-Apr-2025 17:37:45

989 Views

Among several file-handling operations in Python, the need to list all files in a directory is the most common one, and it's quite straightforward. Python offers a module named os that provides functions to work with the operating system, the directories, and the files seamlessly. In this article, we will cover ways of listing all files in a directory. The following are the different methods used to list all files in a dictionary using Python - os.listdir(): list all files in a directory os.walk(): Recursively lists all files in subdirectories ... Read More

C++ Program to Implement Heap Sort

Nishu Kumari
Updated on 17-Apr-2025 16:55:01

1K+ Views

The Heap Sort is a comparison-based sorting algorithm that sorts the numbers using a binary heap. It is an in-place sorting method, that means it sorts the array without needing any extra space. In this article, we have been given an unsorted array and our task is to implement the heap sort in C++. What is Heap Sort? The heap sort is an efficient sorting technique that first constructs the heap ADT and then removes the root element to swap it with the node having minimum value at the leaf position. Then we use the heapify method ... Read More

Implement Selection Sort in C++

Ravi Ranjan
Updated on 17-Apr-2025 16:53:03

22K+ Views

The selection sort is an in-place comparison-based simple sorting algorithm. In the selection sort technique, the list is divided into two parts: sorted and unsorted. The minimum element from the unsorted part is selected and swapped with the element at the beginning of the list. Similarly, the next minimum value from the unsorted list is placed at the next position in the sorted list, and this keeps repeating until the whole array is sorted. In this article, we have an unsorted array. Our task is to sort this array using selection sort in C++. Here is an example of selection ... Read More

Call Python File from Within PHP

SaiKrishna Tavva
Updated on 17-Apr-2025 16:49:51

11K+ Views

In PHP, we can execute Python scripts using built-in functions such as shell_exec(), exec() or popen() by enabling seamless integration between the two languages. Below are three methods to run a Python script from PHP with examples and explanations of each - Using 'shell_exec()' function One way to execute a Python script is by using the shell_exec function. This function runs a command via the shell and returns the output as a string. This function ensures that the command is safe to run by escaping any characters that could be harmful. The output of this script is sent back to ... Read More

Declare a Multi-Dimensional Dictionary in Python

Niharika Aitam
Updated on 17-Apr-2025 16:45:32

1K+ Views

Multidimensional Dictionaries in python Multidimensional dictionaries are part of the dictionaries in Python, which are used to store data. Created by assigning a dictionary to a key within another dictionary, these structures are represented by curly braces {} and can accommodate any data type. Their mutable nature allows modifications after creation. They are composed of unique key-value pairs, separated by a colon (:). While keys are unique, values can be duplicated. Accessing values requires using keys, as dictionaries do not support indexing. To retrieve specific key values, use the key combined with indexing. Syntax The following is the syntax for ... Read More

Create an Empty List in Python

Akshitha Mote
Updated on 17-Apr-2025 16:42:25

795 Views

In Python, list is one of the built-in data types. A Python list is a sequence of items separated by commas, enclosed in square brackets [ ]. The items in a Python list need not be of the same data type.  In this article, we will discuss different ways to create an empty list in Python. Using Square Brackets This is one of the simplest way to create an empty list to using square brackets[]. An empty list means the list has no elements at the time of creation, but we can add items to it later when needed. my_list=[] ... Read More

Advertisements