Programming Articles

Page 447 of 2547

How to use Python Pandas to find the total number of count for more than one special characters present in each word in a given series?

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 705 Views

When working with text data in Pandas, you might need to count words containing multiple special characters. This tutorial shows how to find the total count of words that have more than one special character in a given Series. Input Data Let's start with a sample series containing words with special characters ? import pandas as pd data = pd.Series(["fruits!!", "*cakes*", "$nuts", "#drinks"]) print(data) 0 fruits!! 1 *cakes* 2 $nuts 3 #drinks dtype: object ...

Read More

Write a program in Python to replace all the 0's with 5 in a given number

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 784 Views

Given an integer N, the task is to replace all the 0's that appear in the number with '5'. However, leading zeros are ignored as they don't affect the number's value. For example, if N = 1007, the output should be 1557. Example Cases Input-1 − N = 1007 Output − 1557 Explanation − The given number has 2 zeros which when replaced by '5' results in the output as 1557. Input-2 − N = 105 Output − 155 Explanation − ...

Read More

Majority Element in Python

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 3K+ Views

The majority element is an element that appears more than half the times in an array. For example, in an array of size 8, a majority element must appear at least 5 times. Python provides several approaches to find the majority element efficiently. Problem Definition Given an array of integers, find the element that appears more than n/2 times, where n is the array size. If no such element exists, return -1. Example 1 ? Input: [2, 1, 1, 2, 2, 2] Output: 2 Explanation: Element 2 appears 4 times out of 6, which is ...

Read More

Write a program in Python to count the number of digits in a given number N

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 8K+ Views

Let's suppose we have given a number N. The task is to find the total number of digits present in the number. For example, Input-1 − N = 891452 Output − 6 Explanation − Since the given number 891452 contains 6 digits, we will return '6' in this case. Input-2 − N = 74515 Output − 5 Explanation − Since the given number 74515 contains 5 digits, we will print the output as 5. The Approach Used to Solve This Problem ...

Read More

Count Good Meals in Python

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 400 Views

A good meal contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two different foods to make a good meal. Given an array of integers arr where arr[i] is the deliciousness of the ith item of food, we need to return the number of different good meals you can make from this list. Examples Input-1 − arr = [1, 3, 5, 7, 9] Output − 4 Explanation − The good meals are (1, 3), (1, 7), (3, ...

Read More

Birthday Paradox in Python

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 1K+ Views

The Birthday Paradox is a famous probability problem that asks: "How many people need to be in a room before there's a 50% chance that two people share the same birthday?" The counterintuitive answer is just 23 people! This paradox demonstrates how our intuition about probability can be misleading. Understanding the Mathematics The probability that two people have different birthdays is 364/365, which equals (1 - 1/365) in a non-leap year. For multiple people, the probability that all have different birthdays is: P(different) = 1 × (1-1/365) × (1-2/365) × (1-3/365) × ... Therefore, ...

Read More

How to set window size using phantomjs and selenium webdriver in Python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 25-Mar-2026 386 Views

We can set window size using PhantomJS and Selenium webdriver in Python. PhantomJS is a headless browser that allows automated testing without displaying a GUI. To work with PhantomJS, we create a driver object of the webdriver.PhantomJS class and pass the path to the phantomjs.exe driver file as a parameter. To set the window size, we use the set_window_size method and pass the width and height dimensions as parameters. We can also retrieve the current window size using the get_window_size method. Syntax driver.set_window_size(width, height) print(driver.get_window_size()) Parameters width − The desired window width ...

Read More

How can Keras be used to remove a layer from the model using Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 3K+ Views

TensorFlow is a machine learning framework provided by Google. It is an open-source framework used with Python to implement algorithms, deep learning applications, and much more. It is used in research and for production purposes. Keras was developed as part of research for the project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System). Keras is a deep learning API written in Python. It is a high-level API that provides a productive interface to help solve machine learning problems. Keras is highly scalable and comes with cross-platform abilities. This means Keras can be run on TPU or clusters of GPUs. ...

Read More

How can Bokeh be used to create step line plot in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 258 Views

Bokeh is a Python package that helps in data visualization. It is an open source project. Bokeh renders its plots using HTML and JavaScript, making it ideal for web-based dashboards and interactive applications. Bokeh can be easily used in conjunction with NumPy, Pandas, and other Python packages. It can be used to produce interactive plots, dashboards, and real-time data visualizations. Installation You can install Bokeh using pip or conda ? pip3 install bokeh Or using Anaconda ? conda install bokeh Creating Step Line Plots The step() function in ...

Read More

Explain how a sequential model (Dense Layer) be built in Tensorflow using Python

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 397 Views

TensorFlow is a machine learning framework provided by Google. It is an open-source framework used with Python to implement algorithms, deep learning applications, and much more. It is used for both research and production purposes. The 'tensorflow' package can be installed on Windows using the below command: pip install tensorflow The layers API is part of the Keras API. Keras is a high-level deep learning API written in Python that runs on top of TensorFlow. It provides essential abstractions and building blocks for developing machine learning solutions with a productive interface. Keras is already ...

Read More
Showing 4461–4470 of 25,466 articles
« Prev 1 445 446 447 448 449 2547 Next »
Advertisements