Splitting a String into separate words is one of the most common operations performed on a String. We can use the split() method of the str class to perform the split operation. In this Python Split String article, we will learn how to split string in Python based on a delimiter, comma, space, character, regex, and multiple delimiters. … [Read more...]
Python Strings Basics and String Operations
Python String is one of the most popular data types in Python. A string is a sequence of characters such as names, special characters, or numbers to display. In this article, we will learn about the Python Strings Basics and some String Operations. … [Read more...]
Prime Number Program in Python with Optimization [Sieve of Eratosthenes & 6n+1 / 6n-1 ]
What is a Prime Number? A Prime Number is a number which is greater than 1 and divisible by 1 and only itself. Some of the Prime Numbers are 2, 3, 5, 7, 11, 13, 17... In this article, let's create a Prime Number Program in Python and learn some Optimization techniques. … [Read more...]
Python Keywords and Identifiers
In this article, let's learn about Python Keywords and Identifiers. Keywords in Python are the reserved words and cannot be used as variable names, function names, or class names, etc. Python Identifiers are nothing but the name which we give to identify a variable, function, object, etc. … [Read more...]
Python Sieve of Eratosthenes
In this article, we will learn how to implement Python Sieve of Eratosthenes to find Prime Numbers. Sieve of Eratosthenes is an ancient algorithm used to find the prime numbers up to any given limit and it is one of the efficient ways to find prime numbers. … [Read more...]
Python Data Types | Immutable & Mutable Types
In this article, we will learn about Python Data Types. Data types represent the type of data stored in a variable. Since Python is a dynamically typed language, there is no need to declare the data type during declaration explicitly, and the Python interpreter automatically assigns the value to its type. Below are the built-in data types available in Python Boolean … [Read more...]
8 Different Ways to Merge Two Dictionaries in Python
In this article, we will discuss the different ways to merge two dictionaries in Python. Python dictionary is an unordered collection of items. We will be using the below approaches to merge two dictionaries update() method copy() and update() method ** operator dict() constructor dict() with **kwargs Concatenation in dict() collections - ChainMap … [Read more...]
Python Numbers – Integers, Floating-Point, and Complex Numbers
Python Numbers can be classified into three types Integers, Floating-point, and Complex numbers, and there is no explicit type declaration needed in Python. The numbers which we type in will be automatically interpreted as a number. … [Read more...]
How to get the Iteration index in for loop in Python
In this article, we will learn how to get the iteration index in for loop in Python. In Python, we usually iterate a for loop with the in operator or range() function. If suppose you are iterating a list of 5 elements and you want to perform some special operation on the 3rd element, how do you do it in Python? … [Read more...]
Python *args and **kwargs – Pass multiple arguments to a function
In this article, let's learn about Python *args and **kwargs and its functionality. *args and **kwargs are often used as parameters in function definitions enabling us to pass multiple arguments to the function. *args as a parameter in function definition allows you to pass a non-keyworded, variable-length tuple to the calling function. **kwargs as a parameter in function … [Read more...]
Python Comments – Single Line and Multi Line Comments
Comments are a handy tool for programmers and considered as one of the best practices for developers. Even though comments will not alter the execution flow or change the outcome of the code, it improves the readability of the code and helps you to understand why a particular block of code was written at a later point. In this article, we will learn about Python Comments, both … [Read more...]
Python Hello World Program
Python is a simple, easy to learn yet powerful programming language. Guido van Rossum created Python and released in 1991. Python is so simple as there are no type declarations of variables, parameters, functions in the code, which makes the code short and flexible. In simple words, we can say Python drives the current world software development by providing libraries for … [Read more...]