How to Convert String To Byte Array Python

Python String to Byte Array Using bytes() Function

In this Python tutorial, I will show you how to convert string to byte array Python. I needed to send the user a message in my chat application over the network. Since you can’t send the raw message over the network, it is good practice to convert the message into bytes and send it over …

Read more…

Python Get File Extension

Python Get File Extension Using OS Module

In this Python tutorial, you will learn about Python get file extension using the two methods. In my file management project, I had to implement the functionality of filtering files by extension to process files with specific extensions. So, I used the Python modern module ‘pathlib’ to get the file extension. Also, I have explained …

Read more…

Tuple Concatenation Python

Concatenate Two Tuples Python Using Plus Operator (+)

In this Python tutorial, I will discuss tuple concatenation in Python, combining multiple tuples into a single tuple. Suppose you need to maintain consistency and data integrity. You can use the tuple, as once created, it can’t be altered; the only option is to create a new one from the existing one. So, in this …

Read more…

Iterate through Dictionary with multiple values in Python

Python Iterate Dictionary Using the For Loop

In this Python tutorial, you will learn about Python iterating through a dictionary with multiple values. I was creating a user management application in Python; I needed a way to store the user information containing the user details, and for that, I used the dictionary. I used the for loop method to access the user …

Read more…

How to Initialize Dictionary with Default Values

Python Initialize Dictionary Using dict() Function.JPG

In this Python tutorial, I will explain several methods for initializing a dictionary with default values. While analysing the dataset based on the log files, I wanted to count the occurrences of various times, such as product IDs in a sales log. To simplify the counting logic. I had to initialize the dictionary with a …

Read more…

What are the Different ways to Create Strings in Python

Creating and Storing Strings in Python using the Single Quote

In this Python tutorial, you will learn “what are the different ways to create strings in Python?”. A string is a data type in Python that denotes a collection of characters. A string is immutable, meaning once created, you can’t change it. Using the string, you can represent the text. In my Python project, I …

Read more…

Python Dictionary Find Key By Value

Python Dict Find Key By Value Using Loop

In this Python tutorial, you will learn about Python dictionaries to find keys by value. This concept is less implemented or quite opposed to getting the values by key concepts. However, I have provided several examples of how implementing these concepts in your project can benefit you. One example is getting the product name based …

Read more…

Python Get Filename From Path

Python File Name Using Os Module

In this Python tutorial, you will learn about Python to get a filename from a path. While building the file management app in Python, at some point, I needed to implement the functionality of showing the file with their name. I used the Python ‘os’ module to get the file’s name to achieve that. Additionally, …

Read more…

How to Perform String Slicing in Python

string slicing in python with negative slicing example

In this Python tutorial, I will teach you how to do string slicing in Python. In my data science project, I had to perform string slicing, where I needed to extract the domain part of the URLs in the dataset. For that, I applied the slicing concepts using Python’s slicing operator. In this tutorial, I …

Read more…

Python File methods (With Useful Examples)

Viewing the File Before Using the Flush() File Method in Python

If you are a beginner and want to learn about Python file methods, this tutorial will explain them. Whenever I work on a Python project, I must interact with files on my system. I use the Python file methods to perform certain operations on the file, such as reading, writing, truncating, etc. In this tutorial, …

Read more…