Find the Path to a Given File in Python

Jaisshree
Updated on 23-Aug-2023 09:13:13

3K+ Views

Python users frequently work with files, particularly when altering, reading, or writing data to files. However, identifying a file's path is necessary before performing any operation on it. Simply said, a file's path refers to the system location or directory where it is kept. There are four major types of methods to use to find the path to the given file in Python − Pathlib Module OS Module os.path.join() method os.getcwd() method Approach 1: Using the Pathlib Module The pathlib module in Python makes everything very feasible and efficient to make file paths. absolute() − An absolute path ... Read More

Find Maximum and Minimum Element in a NumPy Array

Jaisshree
Updated on 23-Aug-2023 09:09:43

2K+ Views

The well-known open-source Python library NumPy is used for numerical computing. Large, multi-dimensional arrays and matrices are supported, along with a sizable number of sophisticated mathematical operations that can be used to work effectively on these arrays. When working with NumPy arrays, finding the maximum and minimum elements is often necessary. Method 1:Using max() and min() Functions The following code demonstrates creating an array of integers. We then use the max() and min() functions to find the highest and lowest value elements in the array, respectively. Algorithm Import the desired Numpy library. Create a 1D numpy array with integer ... Read More

Finding Memory Usage of an Object in Python

Jaisshree
Updated on 23-Aug-2023 09:08:06

2K+ Views

Memory is frequently set up in a computer system as a series of binary digits, or bits. Each byte is given a unique memory location that may be used to read from or write to the byte's value. Bytes, which can be interpreted as characters, integers, floating-point numbers, or other data kinds, are used to store data in memory. You may measure memory use in Python with the aid of tools like the built-in sys.getsizeof() and asizeof() from pympler. Method 1: Using Getsizeof() Function The amount of memory required by an object or data structure may be ascertained with ... Read More

Filling Area Chart Using Plotly in Python

Jaisshree
Updated on 23-Aug-2023 09:02:55

482 Views

Plotly is a library in Python which is very useful in plotting various kinds of graphs and charts. It is an interactive visualization library used to create quality graphs for publications. Somes of the graphs and charts that can be visualized with plotly include line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts, and bubble charts. Filled Area Chart Filled area plot is an enhanced module in plotly that analyzes a variety of data and produces user friendly figures that are easily readable. The filled area harmonizes with a particular value ... Read More

File Sharing App Using Python

Jaisshree
Updated on 23-Aug-2023 09:00:47

1K+ Views

Bluetooth and WhatsApp are often used to send files from one device to another. Although both these methods are quite convenient, having a simple QR Code to tap into other devices’ documents is satisfyingly fun. Especially, when this can be done in minutes using Python. With the help of Python combined with the concepts of computer networks, we can make a simple python application to share documents over different devices. This application will provide both an IP address as well as a QR Code. As required, you can scan the code or type in the IP address in the device ... Read More

File Explorer in Python Using Tkinter

Jaisshree
Updated on 23-Aug-2023 08:58:05

4K+ Views

Tkinter is a Python toolkit library used to build interfaces, design applications and create Graphical User Interfaces (GUIs). It originated from the Tcl programming language, which Python uses as a wrapper around Tk GUI Toolkit. Now it is used mostly with Python. It is a versatile tool where you can develop pages, buttons and customize fonts and background colours according to your preference. A file explorer is a tool that allows the user to navigate through all existing files present in the system for ease of access to files and open them without much difficulty. It offers a centralized database, ... Read More

Fidget Spinner Using Python

Jaisshree
Updated on 23-Aug-2023 08:56:52

808 Views

Fidget Spinner is one of the fun and interesting projects that can be made possible using existing Python modules. A fidget spinner is a device that remains stationary in one place and keeps spinning as long as the person flicks it constantly, or else it will stop spinning completely. To simulate this, we can use libraries like pygame which provides us with an interface which can be customized to our liking while building games in general. There is also another such library which will be used for running the fidget spinner, similar to its real-life counterpart. Installation and Syntax To ... Read More

Element Methods in Selenium Python

Jaisshree
Updated on 23-Aug-2023 08:55:35

712 Views

Selenium, an open source automation testing tool is used with other programming scripts like python , java , javascript and pearl to test web applications. It is widely used by developers for automation testing. Element Methods of Selenium 1. send_keys () − Used for setting up input text boxes which includes edit box, text area, fields inside forms and modifier keys. It extends properties from the keys class. Return Type − null 2. is_selected() − Checks if an element is selected or not by the user Return Type − boolean value ( True or False). 3. is_displayed() − Checks ... Read More

Read JSON File in Python

pawandeep
Updated on 23-Aug-2023 03:50:38

79K+ Views

What is a JSON file?JSON stands for JavaScript Object Notation. It is commonly used for transmitting data in web applications (such as sending data from server to client to display on the web pages).Sample JSON FileExample 1: {    "fruit": "Apple",    "size": "Large",    "color": "Red" }Example 2: {    'name': 'Karan',    'languages': ['English', 'French'] }The json file will have .json extensionRead JSON file in PythonPython has an in-built package called json which can be used to work with JSON data and to read JSON files. The json module has many functions among which load() and loads() are ... Read More

Compound Data Types and Data Structures in Python

Vikram Chiluka
Updated on 23-Aug-2023 03:39:55

5K+ Views

In this article, we will explain what are the compound datatypes and data structures in python. Variables have so far only stored one value. What if we wish to save many related values? We could simply create distinct variables for each. But what if we don't know how many values will be present? What if we wish to use these values within a loop? Compound data structures are data types that can store a large number of values. In Python, there are various types of compound data structures. We will mostly concentrate on Lists. In the end, we will ... Read More

Advertisements