AmitDiwan has Published 10744 Articles

Replace All Occurrences of a Python Substring with a New String?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:24:19

288 Views

In this article, we will implement various example to replace all occurrences of a substring with a new string. Let’s say we have the following string − Hi, How are you? How have you been? We have to replace all occurrences of substring “How “ with “Demo”. Therefore, the ... Read More

How to Merge Elements in a Python Sequence?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:19:18

2K+ Views

Python Sequences includes Strings, Lists, Tuples, etc. We can merge elements of a Python sequence using different ways. Merge Elements in a Python List Example The join() method is used to merge elements − # List myList = ['H', 'O', 'W', 'A', 'R', 'E', 'Y', 'O', 'U'] # Display ... Read More

Python - Check If All the Characters in a String Are Alphanumeric?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:17:18

519 Views

To check if all the characters in a string are alphanumeric, we can use the isalnum() method in Python and Regex also. First, let us understand what is alphanumeric. What is Alphanumeric? Alphanumeric includes both letters and numbers i.e., alphabet letter (a-z) and numbers (0-9). Examples: A, a, k, K, ... Read More

What Does the // Operator Do?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:15:37

616 Views

In Python, the // is the double slash operator i.e. Floor Divison. The // operator is used to perform division that rounds the result down to the nearest integer. The usage of the // operator is quite easy. We will also compare the results with single slash division. Let us ... Read More

What are Pickling and Unpickling in Python?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:13:28

9K+ Views

To serialize and de-serialize a Python object structure, we have the Pickle module in Python. The pickle module implements binary protocols for serializing and de-serializing a Python object structure. Pickling is the process through which a Python object hierarchy is converted into a byte stream. To serialize an object hierarchy, ... Read More

Numpy Array advantage over a Nested List

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 12:11:12

2K+ Views

In this article, we will learn about the advantages of a Numpy array with a Nested List in Python. The Numpy array definitely has advantages over a Nested. Let’s see the reasons − The array in Numpy executes faster than a Nested List. A Nested List consumes more memory ... Read More

Explain how Python is an interpreted language

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 11:59:15

5K+ Views

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP. Steps of Execution Step1 − A Python source code is written by the ... Read More

How to use the slicing operator in Python?

AmitDiwan

AmitDiwan

Updated on 15-Sep-2022 11:54:39

3K+ Views

The slice operator is used to slice a string. The slice() function can also be use for the same purpose. We will work around the slice operator with some examples What is Slicing? Slicing in Python gets a sub-string from a string. The slicing range is set as parameters i.e. ... Read More

Reloading modules in Python?

AmitDiwan

AmitDiwan

Updated on 16-Aug-2022 12:12:47

19K+ Views

The reload() is used to reload a previously imported module or loaded module. This comes handy in a situation where you repeatedly run a test script during an interactive session, it always uses the first version of the modules we are developing, even we have made changes to the code. ... Read More

What is the process of compilation and linking in python?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:51:26

7K+ Views

Compilation − The source code in python is saved as a .py file which is then compiled into a format known as byte code, byte code is then converted to machine code. After the compilation, the code is stored in .pyc files and is regenerated when the source is updated. ... Read More

Advertisements