Found 10784 Articles for Python

Check if the Sum of Digits of a Number N Divides It

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:19:17

111 Views

The N number is the special number of integer type that calculates the individual digit of sum. So, this sum will be divisible by its own number. Let’s take an example of this. The given integer number, N = 36 The sum of each digit, 3 + 6 = 9 Therefore, 36 is successfully divisible by 9 and it verifies for N divides it. Algorithm The following steps are- Step 1: We will start the program by mentioning the header file iostream. Step 2: Common Matches:- Then used the function definition digit_sum() that accepts the parameter a variable n ... Read More

How to Sort a Pandas DataFrame by Date?

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:16:25

2K+ Views

Python’s Pandas DataFrame defines the two-dimensional structure that consists of rows and columns. The main feature of pandas is an easier way of handing the given data. In Python, we have some in-built functions such as to_datetime(), sorted(), lambda, and, sort_value() will be Sort a Pandas DataFrame by Date. Syntax The following syntax is used in the examples- to_datetime() The to_datetime() is an in-built function in Python that convert string dates into date-time objects. sorted() The built-in function sorted() of Python states that the list can be sort as specified iterable objects. lambda This lambda function in ... Read More

Python - Filter Tuples with All Even Elements

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:14:59

171 Views

The problem statement allows us to determine the position of the desired string in the list, which can be useful for various purposes, such as accessing or manipulating elements at that specific index. In Python, we have some built-in functions like reduce(), str(), filter(), lambda, and, all() that will be used to Find Index Containing String in List. Syntax The following syntax is used in the examples- reduce() This function is defined under the functools module str() This is a built-in method in Python that can convert the specified value into a string. filter() The ... Read More

Program to check if a String in Java contains only whitespaces

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:10:38

2K+ Views

The whitespaces of JAVA represent either an empty string or an escape sequence character. In Java, we have some built-in functions such as isEmpty(), lenThe whitespaces of JAVA represent either an empty string or an escape sequence character. In Java, we have some built-in functions such as isEmpty(), length(), isWhitespace(), and, charAt() that will be used to check if a String in Java contains only whitespaces. The whitespaces in the program are only used for formatting purposes such as (new line), \t(horizontal tab), \v(vertical tab), etc. Syntax The following syntax is used in the examples- isEmpty() The built-in function ... Read More

Check if a Word is Present in a Sentence

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:05:20

611 Views

A sentence is a group of words that are present in a string. In this problem statement, we need to set a specific word and check whether the word is present in a given string or not. In C++, we have some pre-defined functions such as find(), npos(), and istringstream() will be used to Check if a word is present in a sentence. Using Standard library Function The program uses a standard library function that allows the programmer to use pre-existing functions of the C compiler such as find() and npos() to perform certain tasks. Syntax The following syntax is ... Read More

Check if a number with even number of digits is palindrome or not

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:02:54

196 Views

The palindrome refers to same number when the digits are reversed. In this program, we need to set the condition and operation based on an even number of digits to identify whether the given input satisfied for palindrome or not. In C++, we have STL(Standard template library) functions such as to_string(), length(), rbegin(), rend(), and, push_back() will be used to Check if a number with an even number of digits is palindrome or not. For example- 2662, 42124, 44, 888, etc are satisfied for even digit palindrome numbers. Using for loop and if-else statement The program uses for loop to ... Read More

Python - K List Dictionary Mesh

Tapas Kumar Ghosh
Updated on 17-Aug-2023 17:58:41

70 Views

The term dictionary Mesh is defined by storing the value pair of every key set to dictionary. To include the K list in the dictionary means to insert the list as value pair. In Python, we have some built-in functions such as defaultdict() and lambda will be used to solve the K list dictionary Mesh. Let’s take an example of this. Given input list, list1 = [10, 20, 30] list2 = [40, 50] The final output becomes: {10: {40: [], 50: []}, 20: {40: [], 50: []}, 30: {40: [], 50: []}} Syntax The following syntax is used ... Read More

Python Tensorflow - tf.keras.Conv2D() Function

Parth Shukla
Updated on 17-Aug-2023 16:40:23

484 Views

Introduction In deep learning, computer vision is one of the most important fields which is used for many complex and advanced tasks related to image datasets. It is used for image analysis, object detection, segmentations, etc. This is mainly achieved with the combination of TensorFlow and Keras, which offers several inbuilt functions which automate and make the process of model training very easy. The Conv2D is also one of the most useful and powerful functions in the Keras library, which is used for applying convolutional operations to the image. In this article, we will discuss the Conv2D function ... Read More

Compute Classification Report and Confusion Matrics in Python

Parth Shukla
Updated on 17-Aug-2023 16:31:25

425 Views

Introduction In machine learning, classification problems are one of the most widely seen problems, where machine learning models are built to classify several categories of the target variables. However, the classification report and confusion matrics are used in order to evaluate the performance of the model and to check where the model is making mistakes. In this article, we will discuss the classification report and confusion matrics, what they are, how we can use them, and what their interpretation is by calculating the same code examples in Python. This article will help one to clear an idea about ... Read More

How to iterate over Columns in Numpy

Tapas Kumar Ghosh
Updated on 16-Aug-2023 16:15:40

987 Views

The name Numpy stands for Numerical Python. It helps to solve the mathematical operation on an array. In Python, we have some built-in functions such as nditor(), T(), array(), shape[], and apply_along_axis() that will be used to iterate over columns in Numpy. Syntax The following syntax is used in the examples- nditer() The NumPy module contains this built-in function for iterator objects. T() This function refers to transposing of the index in a column dataframe. array() This is a built-in function in Python that creates the array. An array is defined by collecting the items of ... Read More

Advertisements