Python Articles

Page 155 of 855

Hashing Passwords in Python with BCrypt

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 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. Installation First, install the BCrypt library using pip: ...

Read More

Handling Categorical Data in Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 1K+ Views

Data that only includes a few values is referred to as categorical data, often known as categories or levels. 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. Ordinal categorical data refers to information that is naturally ranked or ordered, such as customer satisfaction levels or educational attainment. Setup Install the required libraries for handling categorical data ? pip install pandas pip install scikit-learn pip install category_encoders Categorical data is often represented as text ...

Read More

Fun Fact Generator Web App in Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 1K+ Views

Flask is a lightweight Python web framework that makes it easy to build web applications. In this tutorial, we'll create a Fun Fact Generator web app that displays random interesting facts to users. This project demonstrates Flask basics including routing, templates, and dynamic content generation. Prerequisites and Setup Before starting, ensure you have Python 3.x installed. Install Flask using pip − pip install flask Create the following project structure − Project Folder/ ├── app.py └── templates/ └── index.html How It Works Our Fun Fact Generator ...

Read More

fromtimestamp() Function Of Datetime.date Class in Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 6K+ Views

The fromtimestamp() function of the Python datetime.date class converts a Unix timestamp into a date object. A timestamp represents the duration since the epoch (January 1, 1970, 00:00:00 UTC). This function is particularly useful when working with databases, log files, or APIs that store dates as timestamps. Syntax datetime.date.fromtimestamp(timestamp) The method takes a single parameter − the timestamp value in seconds − and returns a date object. Since it's a class method, you must call it using the class name datetime.date. Basic Example import datetime # Create a timestamp value (January ...

Read More

Food Recognition Selenium using Calorie Mama API

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 582 Views

Selenium WebDriver is an open-source automation tool for web browsers that provides a platform-independent testing framework. When combined with the Calorie Mama API, which uses deep learning and computer vision algorithms to recognize food items and their nutritional values from images, we can automate food recognition tasks. In this tutorial, we'll explore how to use Selenium WebDriver to automate the process of uploading food images to the Calorie Mama API and retrieving nutritional information programmatically. Prerequisites and Setup Firefox Browser Installation Download Firefox from the official website Install Firefox, which will be placed in C:\Program ...

Read More

Ethical Hacking with Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 1K+ Views

Python is an increasingly popular programming language for Ethical Hacking, especially in today's digital world, where security is paramount. With the rise of cybercrime, it's essential to take proactive measures to safeguard our online assets. Ethical Hacking is a critical step in this process, involving the identification and resolution of system vulnerabilities before they can be exploited by malicious hackers. This article will explore how Python is used for Ethical Hacking, including its advantages and best practices. Basics of Ethical Hacking Hacking is broadly classified into three types − Black Hat Hacking, White Hat Hacking, and Grey Hat ...

Read More

Python Program to Replace the Spaces of a String with a Specific Character

Rohan Singh
Rohan Singh
Updated on 27-Mar-2026 15K+ Views

In Python, spaces in a string can be replaced with specific characters using the replace() method. The replace() method substitutes all occurrences of a specified substring with a new substring. This article demonstrates how to use replace() to replace spaces with various characters. Syntax The syntax of the replace() method is ? string.replace(old, new[, count]) Parameters old − The substring to be replaced new − The replacement substring count (optional) − Number of occurrences to replace. If omitted, all occurrences are replaced Example 1: Replace Spaces with Hyphens To ...

Read More

Python Program to open a file in the read-write mode without truncating the file

Rohan Singh
Rohan Singh
Updated on 27-Mar-2026 3K+ Views

In Python, we can open a file in read-write mode without truncating it by using the a+ mode. Truncating a file refers to deleting its existing content before opening. This article demonstrates how to preserve existing data while still being able to read and write to files. What is a+ Mode? The a+ mode opens a file for both reading and writing without truncating existing content. New data is appended to the end of the file, preserving all original content. The file pointer starts at the end for writing operations. Syntax open('filename', 'a+') ...

Read More

Python Program to Insert a string into another string

Rohan Singh
Rohan Singh
Updated on 27-Mar-2026 12K+ Views

In Python, inserting a string into another string is a common operation for text manipulation. Python provides several methods including concatenation, string interpolation, slicing, and the replace() method. Each approach has its own advantages depending on your specific use case. Using Concatenation Operator (+) String concatenation joins multiple strings together using the (+) operator. This method is straightforward and works well when you know the exact position where you want to insert the string ? first_part = "Hello, " second_part = "world!" inserted_text = "Python " new_string = first_part + inserted_text + second_part print(new_string) ...

Read More

Python Program to implement switch statement on String

Rohan Singh
Rohan Singh
Updated on 27-Mar-2026 3K+ Views

In Python, we can implement switch statements on a string using the dictionary-based approach, class-based approach, and lambda-based approach. Unlike other programming languages like Java, C++, etc., Python does not have a built-in switch statement. In this article, we will see how we can achieve the switch statement functionality in Python using different approaches. The Switch Statement in Other Programming Languages Before understanding how Python implements switch statements, we need to understand how switch statements work and how they are implemented in other programming languages. A switch statement is a conditional statement that evaluates an expression and ...

Read More
Showing 1541–1550 of 8,549 articles
« Prev 1 153 154 155 156 157 855 Next »
Advertisements