Found 10476 Articles for Python

Formatting containers using format() in Python

Atharva Shah
Updated on 18-Apr-2023 12:41:33

271 Views

When using Python, container style can be a useful means of enhancing the readability and maintainability of code. You can style lists, tuples, dictionaries, sets, and even classes quickly and simply using this method. You can adjust how your data is presented by aligning columns, adding padding, and setting accuracy by using the built-in format() method. In this article, we'll take a deep dive into container formatting using format() in Python, including various types of containers and how to use them with the format() function. Container Formatting with format() Assuming we have a list of numbers that we want ... Read More

Emulating Numeric Types in Python

Atharva Shah
Updated on 18-Apr-2023 12:39:18

679 Views

Python includes built-in mathematical data structures like complex numbers, floating-point numbers, and integers. But occasionally we might want to develop our own custom-behaved number classes. Here, the idea of imitating number classes is put into use. We can create objects that can be used in the same way as native numeric classes by simulating them. We will look at how to simulate numeric classes in Python in this article. Example 1: Emulating Addition class MyNumber: def __init__(self, x): self.x = x def __add__(self, other): ... Read More

Element wise concatenation of two NumPy arrays of string

Atharva Shah
Updated on 18-Apr-2023 12:36:48

438 Views

Python's element-wise union of two NumPy string arrays is a potent method with a wide range of uses. This blog article will go over NumPy's setup and implementation procedures, the syntax for joining two NumPy string arrays together element-wise in Python, and the underlying method. Element-wise concatenation, for instance, is commonly used in data manipulation tasks to combine two data sets. Installation and Setup Simply use pip or conda. NumPy is a powerful library that provides support for mathematical operations and arrays. Once installed, you can import it into your Python script using the following command − import numpy ... Read More

Difference Between Set vs List vs Tuple

Atharva Shah
Updated on 18-Apr-2023 12:31:35

2K+ Views

The utilization of data structures in Python presents a perplexing and convoluted method of depicting numbers, strings, and other Python objects in a collection of values. Python's built-in data structures, such as lists, tuples, and sets, are captivating and exhibit distinctive traits that differentiate them from one another. These data structures possess an extraordinary capacity to hold groups of objects, rendering them one of a kind. In this article, we will see which among the three fits best with examples. List Items can be changed, added to, or taken out of after they are made. It can also be ... Read More

Difference Between Method Overloading and Method Overriding in Python

Atharva Shah
Updated on 18-Apr-2023 12:28:17

12K+ Views

Methods are important when it comes to Python's object-oriented programming (OOP). They are crucial for isolating functionality within a class and giving things the ability to carry out particular functions. However, two OOP concepts—method overloading and method overriding—can occasionally cause misunderstanding. The distinctions between these two ideas and their applications in Python will be discussed in this article. Syntax Using the "def" verb, the method's name, arguments, and body are all required to define a method in Python. def method_name(parameter1, parameter2, ...): # method body return value Comparison Table Method ... Read More

Hashing Passwords in Python with BCrypt

Atharva Shah
Updated on 18-Apr-2023 12:42:33

12K+ Views

Password hashing is a technique used to store passwords securely. It involves converting plain text passwords into a hashed format that cannot be easily reversed or decrypted. By hashing passwords, even if a hacker gains access to the password database, they will not be able to decipher the passwords. BCrypt is a password hashing algorithm that is considered one of the most secure algorithms for password hashing in Python. BCrypt is designed to be slow, which makes it more difficult for hackers to crack the hashed passwords. In this post, we will explain the syntax, code algorithm, and Python ... Read More

Handling Categorical Data in Python

Atharva Shah
Updated on 18-Apr-2023 12:20:49

981 Views

Data that only includes a few values is referred to as categorical data, often known as categories or levels and it is described in two ways - nominal or ordinal. Data that lacks any intrinsic order, such as colors, genders, or animal species, is represented as nominal categorical data while ordinal categorical data refers to information that is naturally ranked or ordered, such as customer satisfaction levels or educational attainment. We will go through how to handle categorical data in Python in this tutorial. Setup pip install pandas pip install scikit-learn pip install category_encoders Categorical data is often ... Read More

Fun Fact Generator Web App in Python

Atharva Shah
Updated on 18-Apr-2023 12:15:58

1K+ Views

Flask offers a number of features, such as database access, processing of user input, and dynamic data delivery. An effective and user-friendly online application may be made using HTML and simple Python coding. Python gives us the ability to work with data and provide consumers tailored experiences, while Flask makes it easier to create web applications. The data item is also shown in the browser using HTML. You'll have a working Fun Fact Generator web application at the conclusion of this lesson. Setup Make sure we have the necessary frameworks and libraries installed before we start. The only requirements ... Read More

fromtimestamp() Function Of Datetime.date Class in Python

Atharva Shah
Updated on 18-Apr-2023 12:10:08

5K+ Views

The fromtimestamp() function of the Python datetime.date class is useful for converting a timestamp into a date object. A timestamp essentially denotes the duration since the epoch (which took place on January 1, 1970, 00:00:00 UTC). To help you understand the fromtimestamp() function's practical uses, we'll go over the syntax and coding practices involved in utilizing it in this blog article. We'll also include different Python code samples. Syntax datetime.date.fromtimestamp(timestamp) The method returns a date object that represents the timestamp and only requires a single input, the timestamp value in seconds. You must use the class name to access ... Read More

Forward driver method – Selenium Python

Atharva Shah
Updated on 18-Apr-2023 12:07:17

666 Views

This technique is used to navigate forward in a web browser's history and allows Selenium to move forward in the browser's history page executing any new navigation commands. This Forward Driver Method in Selenium Python can improve the efficiency and accuracy of your automated testing scripts. which allows you to quickly move between. Setup Firefox Executable Download the Firefox browser installer from here Once downloaded, install the browser and an exe file will be placed automatically in C:\Program Files\Mozilla Firefox\firefox.exe. We will be needing it later. Gecko Driver Windows Users can download the gecko ... Read More

Advertisements