Python Articles

Page 773 of 855

Copy and paste to your clipboard using the pyperclip module in Python

S Vijay Balaji
S Vijay Balaji
Updated on 11-Feb-2021 2K+ Views

IntroductionWe will be using the pyperclip module in order to copy and paste content to the clipboard. It is cross−platform and works on both Python 2 and Python 3.Copying and pasting from and to the clipboard could be very useful when you want the output of the data to be pasted elsewhere in a different file or software.Getting StartedThe pyperclip module does not come packaged with Python. In order to access it, you must first download and install it. You can do this using the PIP package manager.Launch your terminal and type the command below to install pyperclippip install pyperclipOnce ...

Read More

Accessing the internet using the urllib.request module in Python

S Vijay Balaji
S Vijay Balaji
Updated on 11-Feb-2021 643 Views

IntroductionWe use the urllib.request module in Python to access and open URLs, which most often use the HTTP protocol.The interface used is also very simple for beginners to use and learn; it uses the urlopen function which can fetch various URLs using a variety of different protocols.You will get a better understanding of what we are working with, once we start using its various functionalities. So, let us get started.Getting StartedThe urllib library comes packaged along with Python. So, you do not need to install it separately, but in case you want to add it to your environment and you ...

Read More

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 10-Feb-2021 692 Views

Input − Assume you have a series, 0       fruits!! 1       *cakes* 2       $nuts 3       #drinks dtype: objectInput − The result for the total number of counts for more than one special character in a series is 2.Let us try to find different solutions to this question.Solution 1To solve this, we will follow the steps given below −Define a SeriesCreate special characters list of values.Set the initial value of special character and total special char count value as 0.Create a for loop and access all the values in the ...

Read More

Count Good Meals in Python

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 05-Feb-2021 393 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.Let us suppose we have given an array of integers arr where arr[i] is the deliciousness of the ith item of food, return the number of different good meals you can make from this list.For example, Input-1 −arr[ ] = {1, 3, 5, 7, 9}Output −4Explanation − The good meals are (1, 3), (1, 7), (3, 5) and, (7, 9). Their respective sums are 4, 8, 8, and 16, ...

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 05-Feb-2021 766 Views

Given an Integer N the task is to replace all the 0’s that appear in the number with ‘5’. However, the number with leading ‘0’ cannot be replaced with ‘5’ as it remains unchanged. For example, Input-1 −N = 1007Output −1557Explanation − The given number has 2 zeros which when replaced by ‘5’ results in the output as 1557.Input-2 −N = 00105Output −155Explanation − Since the given number starts with the leading ‘0’ which can be ignored and the output after replacing the 0 in the middle with ‘5’ results the output as 155.Approach to solve this problemTo replace all ...

Read More

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 01-Feb-2021 376 Views

We can set window size using PhantomJS and Selenium webdriver in Python. To work with the PhantomJS, we should create a driver object of the webdriver.PhantomJS class.Then pass the path of the phantomjs.exe driver file as a parameter to the Class. Next, to set the window size, we shall use the set_window_size method and pass the dimensions as parameters to the method.To obtain the window size of the browser, we can use the get_window_size method.Syntaxdriver.set_window_size(800, 1000) print(driver.get_window_size())Examplefrom selenium import webdriver #set phantomjs.exe path driver = webdriver.PhantomJS(executable_path="C:\phantomjs.exe") driver.maximize_window() #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #set new window size driver.set_window_size(800, 880) #obtain window size print(driver.get_window_size()) ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 21-Jan-2021 378 Views

Tensorflow is a machine learning framework that is provided by Google. It is an open−source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes.The ‘tensorflow’ package can be installed on Windows using the below line of code −pip install tensorflowThe layers API is parth of Keras API. Keras means ‘horn’ in Greek. Keras was developed as a part of research for the project ONEIROS (Open ended Neuro-Electronic Intelligent Robot Operating System). Keras is a deep learning API, which is written in Python. It is a ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 21-Jan-2021 3K+ Views

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

Read More

When should a sequential model be used with Tensorflow in Python? Give an example

AmitDiwan
AmitDiwan
Updated on 21-Jan-2021 347 Views

A sequential model is relevant when there is a plain stack of layers. In this stack, every layer has exactly one input tensor and one output tensor. It is not appropriate when the model has multiple inputs or multiple outputs. It is not appropriate when the layers need to be shared. It is not appropriate when the layer has multiple inputs or multiple outputs. It is not appropriate when a non-linear architecture is required.Tensorflow is a machine learning framework that is provided by Google. It is an open−source framework used in conjunction with Python to implement algorithms, deep learning applications ...

Read More

How can Keras be used to save model using hdf5 format in Python?

AmitDiwan
AmitDiwan
Updated on 21-Jan-2021 463 Views

Tensorflow is a machine learning framework that is provided by Google. It is an open−source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes.The ‘tensorflow’ package can be installed on Windows using the below line of code −pip install tensorflowTensor is a data structure used in TensorFlow. It helps connect edges in a flow diagram. This flow diagram is known as the ‘Data flow graph’. Tensors are nothing but multidimensional array or a list.Keras was developed as a part of research for the project ONEIROS ...

Read More
Showing 7721–7730 of 8,547 articles
« Prev 1 771 772 773 774 775 855 Next »
Advertisements