Python Articles - Page 81 of 929

How to check whether user's internet is on or off using Python?

Niharika Aitam
Updated on 09-Aug-2023 15:40:38

14K+ Views

Generally, if you need to verify whether your current system is connected to the internet or not, we can do so, by simply sending request to any of webserver application using the browser or, using the dos command ping. The ping command is typically used to troubleshoot connectivity, reachability, and name resolution. Similarly, in Python we can verify the user’s internet connectivity status either by sending a request to any web application or by using the ping command. Using the request.get() method In python, the modules request helps us to send HTTP requests using Python. By sending requests ... Read More

How to click a href link from bootstrap tabs using Python?

Niharika Aitam
Updated on 09-Aug-2023 15:32:55

286 Views

Bootstrap is the popular HTML, CSS, JavaScript framework which helps us to develop responsive, mobile first, front end web applications. It provides design templates for forms, typography, navigation, buttons and other interface components. Python is the best language to manipulate the web content. The Selenium Library If we need to click a link using Python programming we should use the selenium library. It is the most popular open source automation testing tool which allows us to make the web browsers automate. Selenium is mainly used for the testing purpose of the automated web applications and also used for other ... Read More

How to clone webpage using pywebcopy in python?

Niharika Aitam
Updated on 09-Aug-2023 15:31:44

2K+ Views

Python provides Pywebcopy module, that allows us to download and store the entire website including all the images, HTML pages and other files to our machine. In this module, we have one of the functions namely save_webpage() which allows us to clone the webpage. Installing pywebcopy module Firstly, we have to install the pywebcopy module in the python environment using the following code. pip install pywebcopy On successful installation we will get the following output – Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ Collecting pywebcopy Downloading pywebcopy-7.0.2-py2.py3-none-any.whl (46 kB) . . ... Read More

How to communicate JSON data between Python and Node.js?

Niharika Aitam
Updated on 09-Aug-2023 15:30:11

713 Views

JSON  can be abbreviated as JavaScript Object Notation. It is a text-based file used for transferring and storing data in programming languages. It is supported by the python programming language using a built-in package namely JSON, Its text is given in the quoted string format in which contains a key and value within the curly braces{} as same as a dictionary. For using JSON in python, we have to import the JSON package in python script. JSON package provides several methods, among them one of the methods is dumps. This is used to convert the python tuple objects into ... Read More

How to Color Scatterplot by a variable in Matplotlib?

Niharika Aitam
Updated on 09-Aug-2023 15:17:15

3K+ Views

There are several ways to color scatterplot by a variable in Matplotlib of the python library. We have three parameters in scatter function namely cmap, alpha and c using which we can change the color of the plot. Matplotlib is one of the libraries available in python which is used to plot and visualize the given data. This can be used as the extension of the Numpy library to plot the arrays. This library has the module called pyplot which makes the visualization and plotting the data very easy. This pyplot module has many functions and parameters which ... Read More

Synsets for a word in WordNet in NLP

Mithilesh Pradhan
Updated on 09-Aug-2023 11:53:20

1K+ Views

Introduction WordNet is a large database of words present in the NLTK library in present in many languages for Natural Language related use cases. NLTK library has an interface known as Synset that allows us to look for words in WordNet. Verbs, Nouns, etc. are grouped into sunsets. WordNet and Synsets The below diagram shows the structure of WordNet. In WordNet, the relationship between words is maintained. For example, words like sad are similar and find the application under similar contexts. These words can be interchanged during usage. These kinds of words are grouped for synsets. Each synset is ... Read More

How to choose elements from the list with different probability using NumPy?

Niharika Aitam
Updated on 09-Aug-2023 14:55:24

1K+ Views

There are multiple ways to choose elements from the list with the different probability using the numpy library. In python, NumPy library provides a module named random, which has several functions such as choice(), multinomial() etc., which are used to choose elements from an array with different probabilities. The sum of all probability values defined in the list should be equal to 1. Let’s see each way one by one. Using the random.choice() function The random module provides the function choice(), which is used to calculate a random sample from the given 1-d array with the specified probability distribution. ... Read More

How to check whether the element of a given NumPy array is non-zero?

Niharika Aitam
Updated on 09-Aug-2023 14:53:33

329 Views

There are multiple ways to check whether the element of a given Numpy array is Non-zero. Here are few common ways that we can apply. Using Boolean indexing Boolean Indexing is a technique in Numpy library, that allows for the selection of specific elements from the array based on the Boolean condition. This creates a Boolean mask containing True or False values, which have the same shape and size as per the Boolean condition. Example Following example how to use Boolean indexing to check whether the element of a given numpy array is non-zero. import numpy as np arr = ... Read More

How to check whether the day is a weekday or not using Pandas in Python?

Niharika Aitam
Updated on 09-Aug-2023 14:51:19

4K+ Views

The Python pandas library provides different functions to check whether the day is a weekday or not namely, weekday(), day_name(), isoweekday() etc., Pandas is an open source python library which is used for data manipulation, data analysis, data visualization, data structures etc. This library is widely used in data science and data analysis which provides data cleaning, exploration and transformation. There are many modules and functions available in pandas to work with the given data. Using the weekday() function In python, the weekday() function can be used to determine whether a given day is a weekday or not. This ... Read More

How to check whether specified values are present in NumPy array?

Niharika Aitam
Updated on 09-Aug-2023 14:47:20

9K+ Views

We have different modules and functions available in python language to check whether specified values are present in the given Numpy array. Numpy is abbreviated as Numerical Python, which is a python library used to perform the mathematical, statistical and scientific calculations. The result of the numpy array is returned in the format of array. The arrays can be created in one dimension, two dimension and so on up to 32 dimensions. The Numpy library provides a number of modules and functions which helps us to perform scientific calculations and mathematical calculations. Let’s see each way one by one to ... Read More

Advertisements