A string is a collection of characters that can represent a single word or a complete phrase. Since you can directly assign strings in Python to a literal (unlike other technologies) it is easy to use them. The string literals are typically enclosed in quotes (' ' or " ") and they represent a sequences of characters. However, in some scenarios we will encounter a string that starts with a lowercase b for example, b'WELCOME', Where the b prefix stands for bytes literal. Bytes literals are useful when dealing with binary data, where data is transmitted or ... Read More
The size of an empty class is not zero in C++ as it allocates one unique address to the object in the memory. The size can not be 0, because the two classes can not have the same memory address. So, the size of an empty class is 1 byte which does not hold any data, it is just for memory allocation. In this article, we will see an example of checking the size of an object of an empty class in C++. Demonstrating Size of an Empty Class In this approach, we have two C++ classes. One class ... Read More
In today's digital era, Quick Commerce has become the fastest process of delivering groceries in just 10 to 30 minutes; growing demand for convenience and speed has wholly transformed the retail industry. But how? This article explores the impact of Q-commerce on traditional grocery retail and what it means for the future of shopping. What is Quick Commerce? The word quick refers to instant commerce, where customers can find products or services instantly within 10-20 minutes. The Impact of Quick Commerce on Traditional Grocery Stores Quick Commerce has several impacts on traditional grocery stores − Consumer expectations Change Quick commerce ... Read More
Linear search is a sequential searching algorithm where we traverse every element within the input array and compare it with the key element to be found. The minimum element refers to the smallest element in the array. In this article, we have an array of integers. Our task is to find the minimum element in that array using linear search. Here are the three approaches you can use to find the minimum element: Using Value Using Index Using Pointer Using Value In this approach, ... Read More
Printing numbers from 1 to N is an easy task that can be achieved using loops, but to print numbers from one to N without using a semicolon is a tricky question. We will discuss two different methods to solve this question using iteration and recursion approaches. In this article, our task is to print numbers from 1 to 'n' and we don't have to use a semicolon. The approaches are listed below: Using Iteration Using Recursion Using Iteration This approach uses the iterative approach, where we have used the while loop to print the numbers from 1 to N. The num
The calculation of the sum of the digits of a number in a single statement means that only one line of code will be doing the addition operation. The addition operation should not extend more than one statement. In this article, we have a number and our task is to calculate the sum of the digits of the number in a single statement in c. Here is a list of approaches: Using for Loop Using Recursive Function Using for Loop This approach uses a for loop to calculate the ... Read More
Emulating an n dice roller refers to rolling n number of dice simultaneously. In each roll, all the dice will return a different value from 1 to 6. In this article, we are having 'n' number of dices, our task is to emulate rolling n dices simultaneously. The approaches are mentioned below: Using Loop with rand() Function Using Recursion Using Loop with rand() Function In this approach, we have used the rand() function to generate a random value of dice in each roll. The srand() function with time() is ... Read More
The merge sort technique is based on the divide and conquer technique. We divide the whole data set into smaller parts and merge them into a larger piece in sorted order. It is also very effective for worst cases because this algorithm has lower time complexity for worst cases too. In this article, we have an unsorted array of integers and our task is to implement the merge sort to sort the unsorted array. Steps to to Implement Merge Sort We will be using the steps mentioned below to implement the merge sort algorithm: ... Read More
Converting Integer to ASCII Using chr() Function In Python, the chr() function converts an integer value to the corresponding ASCII (American Standard Code for Information Interchange) character only if the integer range lies between 0 and 127. The chr() function accepts Unicode values within the range of 0 to 1114111. If a value outside this range is provided, the function raises a ValueError. Example In the following example, we have converted integer values to ASCII values using chr() - print(chr(85)) print(chr(100)) print(chr(97)) Following is the output of the above code - U 100 a Example We can ... Read More
In C/C++, Java, etc., ++ and -- operators are defined as increment and decrement operators. In Python, they are not defined as operators. Increment and Decrement Operators in Python In Python, objects are stored in memory. Variables are just labels. Numeric objects are immutable. Hence, they can't be incremented or decremented. However, prefix ++ or -- doesn't give an error but doesn't perform either. As Prefix In the following example, when have used prefix increment which does not raise an error - x=5 print(++x) print(--x) Following is the output of the above code - 5 5 As Postfix In ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP