Convert an octal number(base 8) to its decimal(base 10) representation in Python
Python’s built-in functions are the real deal when it comes to ease many tasks to a great extent, and that’s why I am a big fan of Python. What are built-in functions in Python? Built-in methods are the utility methods provided by the Python interpreter for our use, they come along when you install Python…
https://thecodingbot.com/convert-an-octal-numberbase-8-to-its-decimalbase-10-representation-in-python/
Python’s built-in functions are the real deal when it comes to ease many tasks to a great extent, and that’s why I am a big fan of Python. What are built-in functions in Python? Built-in methods are the utility methods provided by the Python interpreter for our use, they come along when you install Python…
https://thecodingbot.com/convert-an-octal-numberbase-8-to-its-decimalbase-10-representation-in-python/
The Coding Bot
Convert an octal number(base 8) to its decimal(base 10) representation in Python - The Coding Bot
In this blogpost, we will discuss different ways we can convert the octal representation of a number to the decimal equivalent. One approach uses built-in functions while other approach is pure algorithmic...
Find the element that appears once while all the other element appears twice in an array
Problem Statement: Given an array of numbers, all the elements appear twice except one, you need to find that number. Solution: This is a pretty famous interview question and is generally asked either in telephonic interviews or first round. Not that hard problem but the most efficient method to solve this problem is not very obvious. So, either…
https://thecodingbot.com/find-the-element-that-appears-once-while-all-the-other-element-appears-twice-in-an-array/
Problem Statement: Given an array of numbers, all the elements appear twice except one, you need to find that number. Solution: This is a pretty famous interview question and is generally asked either in telephonic interviews or first round. Not that hard problem but the most efficient method to solve this problem is not very obvious. So, either…
https://thecodingbot.com/find-the-element-that-appears-once-while-all-the-other-element-appears-twice-in-an-array/
The Coding Bot
Find the element that appears once while all the other element appears twice in an array - The Coding Bot
Problem Statement: Given an array of numbers, all the elements appear twice except one, you need to find that number.
Insert a node in a sorted linked list
Problem Statement: Given a sorted linked list and a node, insert the node in the linked list such that the linked list still remain sorted. Example: Input: 2 -> 8 -> 12 -> 41 ->NULL, val = 30 Output: 2 -> 8 -> 12 -> 30 ->41 -> NULL. Table of Content: OverviewApproach 1: Insertion…
https://thecodingbot.com/insert-a-node-in-a-sorted-linked-list/
Problem Statement: Given a sorted linked list and a node, insert the node in the linked list such that the linked list still remain sorted. Example: Input: 2 -> 8 -> 12 -> 41 ->NULL, val = 30 Output: 2 -> 8 -> 12 -> 30 ->41 -> NULL. Table of Content: OverviewApproach 1: Insertion…
https://thecodingbot.com/insert-a-node-in-a-sorted-linked-list/
The Coding Bot
Insert a node in a sorted linked list - The Coding Bot
Problem Statement: Given a sorted linked list and a node, insert the node in the linked list such that the linked list still remain sorted.
Insert a Node at the beginning of a Linked List
Problem Statement: Given a linked list(can be an empty list), add a node at the beginning of it. Solution: Table of Content: OverviewApproach 1: Iteratively adding the node at the beginningSteps in detailImplementation of Approach 1Time and Space Complexity discussion.Some more tutorials on the linked list This is a very famous interview question which you…
https://thecodingbot.com/insert-a-node-at-the-beginning-of-a-linked-list/
Problem Statement: Given a linked list(can be an empty list), add a node at the beginning of it. Solution: Table of Content: OverviewApproach 1: Iteratively adding the node at the beginningSteps in detailImplementation of Approach 1Time and Space Complexity discussion.Some more tutorials on the linked list This is a very famous interview question which you…
https://thecodingbot.com/insert-a-node-at-the-beginning-of-a-linked-list/
The Coding Bot
Insert a Node at the beginning of a Linked List - The Coding Bot
Problem Statement: Given a linked list(can be an empty list), add a node at the beginning of it ...
Python’s built-in id() method with examples
In this tutorial, we will talk about a built-in method, and that method is id(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Contents: OverviewWhat are the built-in methods in Python?OverviewThe lifetime…
https://thecodingbot.com/pythons-built-in-id-with-examples/
In this tutorial, we will talk about a built-in method, and that method is id(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Contents: OverviewWhat are the built-in methods in Python?OverviewThe lifetime…
https://thecodingbot.com/pythons-built-in-id-with-examples/
The Coding Bot
Python's built-in id() method with examples - The Coding Bot
In this article, we will discuss about built-in id() method in Python. It returns the "identity" of an object an integer which is unique and constant for an object during its lifetime..
Python’s built-in len() method with examples
Python has many built-in functions. In this article, we will talk about one such function and that function is len(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Content: OverviewDiscussion on…
https://thecodingbot.com/pythons-built-in-len-method-with-examples/
Python has many built-in functions. In this article, we will talk about one such function and that function is len(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Content: OverviewDiscussion on…
https://thecodingbot.com/pythons-built-in-len-method-with-examples/
The Coding Bot
Python's built-in len() method with examples - The Coding Bot
In this article, we will discuss about python's built-in len() function. len() determines the size(number of items) of an object..
Time Complexity of built-in len() function in Python
In this article, we will explicitly focus on the Time Cost of len() function. It is used pretty often, but still, people often get confused about the time complexity of the function. You can find the complete tutorial on the built-in len() function here. Before moving forward, let’s see briefly what len() function does. The…
https://thecodingbot.com/time-complexity-of-built-in-len-function-in-python/
In this article, we will explicitly focus on the Time Cost of len() function. It is used pretty often, but still, people often get confused about the time complexity of the function. You can find the complete tutorial on the built-in len() function here. Before moving forward, let’s see briefly what len() function does. The…
https://thecodingbot.com/time-complexity-of-built-in-len-function-in-python/
The Coding Bot
Time Complexity of built-in len() function in Python - The Coding Bot
In this article, we will discuss about the time complexity of the len() function in Python. It is return the size of the container..
Delete an element from the Python list
Lists are probably python’s most versatile and used data structures. You will find it them in a significant number of python programs. It is also a mutable object. Mutable Object – The Python objects whose value can be changed after initialization without changing its identity are known as Mutable Python Object. In this tutorial, you will…
https://thecodingbot.com/delete-an-element-from-the-python-list/
Lists are probably python’s most versatile and used data structures. You will find it them in a significant number of python programs. It is also a mutable object. Mutable Object – The Python objects whose value can be changed after initialization without changing its identity are known as Mutable Python Object. In this tutorial, you will…
https://thecodingbot.com/delete-an-element-from-the-python-list/
The Coding Bot
Different ways to delete an element from the Python list - The Coding Bot
In this article, I will show you the different ways we can delete an element from the Python list. Later, we will also see how to remove all the occurence of an element from the list.
Find the most common element from the list in Python
There are a couple of ways to solve this problem. In this article, we will look at each method, after that we will see which method among all is the fastest. Table of Content: Approach 1: Using CounterImplementation of Approach 1Approach 2: Using a dictionaryImplementation of Approach 2Approach 3: Using max() and SetImplementation of Approach…
https://thecodingbot.com/find-the-most-common-element-from-the-list-in-python/
There are a couple of ways to solve this problem. In this article, we will look at each method, after that we will see which method among all is the fastest. Table of Content: Approach 1: Using CounterImplementation of Approach 1Approach 2: Using a dictionaryImplementation of Approach 2Approach 3: Using max() and SetImplementation of Approach…
https://thecodingbot.com/find-the-most-common-element-from-the-list-in-python/
The Coding Bot
Find the most common element from the list in Python - The Coding Bot
In this article, we will discuss multiple approaches to find the most common element in a python list , along with that we will see which approach is the fastest...
Check if a column contains specific string in a Pandas Dataframe
Problem Statement: Given a Pandas Dataframe, we need to check if a particular column contains certain string or not. Table of Content: String matching using Series.str.contains()Implementation using Series.str.contains()Slight modification with any() functionImplementation using any() functionExact string matching Implementation demonstrating the exact string matchingSuggested Reading A column is a Pandas Series so we can use amazing…
https://thecodingbot.com/check-if-a-column-contains-specific-string-in-a-pandas-dataframe/
Problem Statement: Given a Pandas Dataframe, we need to check if a particular column contains certain string or not. Table of Content: String matching using Series.str.contains()Implementation using Series.str.contains()Slight modification with any() functionImplementation using any() functionExact string matching Implementation demonstrating the exact string matchingSuggested Reading A column is a Pandas Series so we can use amazing…
https://thecodingbot.com/check-if-a-column-contains-specific-string-in-a-pandas-dataframe/
The Coding Bot
Check if a column contains specific string in a Pandas Dataframe - The Coding Bot
Problem Statement: Given a Pandas Dataframe, we need to check if a particular column contains certain string or not.
Convert a Python list to a Pandas Dataframe
Problem Statement: Given a Python list, convert it into a Pandas Dataframe Before anything, the first thing we need to decide is, how many rows and columns we want in our dataframe. A list of 12 elements can be converted into: 3 columns with 4 rows, 6 columns with 2 rows, 2 columns with 6…
https://thecodingbot.com/convert-a-python-list-to-a-pandas-dataframe/
Problem Statement: Given a Python list, convert it into a Pandas Dataframe Before anything, the first thing we need to decide is, how many rows and columns we want in our dataframe. A list of 12 elements can be converted into: 3 columns with 4 rows, 6 columns with 2 rows, 2 columns with 6…
https://thecodingbot.com/convert-a-python-list-to-a-pandas-dataframe/
The Coding Bot
Convert a Python list to a Pandas Dataframe - The Coding Bot
Given a Python list, convert it into a Pandas Dataframe. Solution: We can convert the python list into a dataframe using numpy and pandas
Python’s list() with examples
In this article, we will discuss yet another python method which is also a Python Constructor, list(). list() is one of the most used built-in python methods. Today, we will see the syntax of list(), the parameters it takes, the value it returns and most importantly what it does, after that some examples to concrete…
https://thecodingbot.com/pythons-list-with-examples/
In this article, we will discuss yet another python method which is also a Python Constructor, list(). list() is one of the most used built-in python methods. Today, we will see the syntax of list(), the parameters it takes, the value it returns and most importantly what it does, after that some examples to concrete…
https://thecodingbot.com/pythons-list-with-examples/
The Coding Bot
Python's list() with examples - The Coding Bot
In this article, we will discuss a built-in python method which is also a constructor, list(). It is one of the most used built-in method.
Product of two numbers using Recursion
Problem Statement: Given two integers, find their product using recursion. Note: Numbers can be both negative and positive. Example: Input: a = 5 , b = 24 Output: product = 120 Input : a = 11, b = 12 Output : 132 Input : a = -2, b = 12 Output : -24 Solution: Table…
https://thecodingbot.com/product-of-two-numbers-using-recursion/
Problem Statement: Given two integers, find their product using recursion. Note: Numbers can be both negative and positive. Example: Input: a = 5 , b = 24 Output: product = 120 Input : a = 11, b = 12 Output : 132 Input : a = -2, b = 12 Output : -24 Solution: Table…
https://thecodingbot.com/product-of-two-numbers-using-recursion/
The Coding Bot
Product of two numbers using Recursion - The Coding Bot
Problem Statement: Given two integers, find their product using recursion. Numbers can be both negative and positive
Sum of the series 1^1 + 2^2 + 3^3 + 4^4+ 5^5 + … n^n using recursion
Problem Statement: Given an integer n, find the sum of the series 1^1 + 2^2 + 3^3 + 4^4+ 5^5 + … n^n using recursion. Example: Input: n = 5 Output = 3413 Explanation: 1^1 + 2^2 + 3^3 + 4^4 + 5^5 = 3413 Input: n = 7 Output = 873612 Explanation: 1^1 +…
https://thecodingbot.com/sum-of-the-series-11-22-33-44-55-nn-using-recursion/
Problem Statement: Given an integer n, find the sum of the series 1^1 + 2^2 + 3^3 + 4^4+ 5^5 + … n^n using recursion. Example: Input: n = 5 Output = 3413 Explanation: 1^1 + 2^2 + 3^3 + 4^4 + 5^5 = 3413 Input: n = 7 Output = 873612 Explanation: 1^1 +…
https://thecodingbot.com/sum-of-the-series-11-22-33-44-55-nn-using-recursion/
The Coding Bot
Sum of the series 1^1 + 2^2 + 3^3 + 4^4+ 5^5 + ... n^n using recursion - The Coding Bot
Problem Statement: Given an integer n, find the sum of the series 1^1 + 2^2 + 3^3 + 4^4+ 5^5 + … n^n using recursion. Example: Input: n = 5 Output = 3413 Explanation: 1^1 + 2^2 + 3^3 + 4^4 + 5^5 = 3413 Input: n = 7 Output = 873612 Explanation: 1^1 + … Continue…
Sum of digits of a number using Recursion
Problem Statement: Given a non-negative integer {0,1,2….}, find the sum of all its digit using recursion. Example: Input: 21212 Output:8 Input: 993311 Output: 26 Input: 12131 Output:8 In this article, we will see how we can find the sum of digits of a number using recursion. The most important prerequisite for recursion is – the…
https://thecodingbot.com/sum-of-digits-of-a-number-using-recursion/
Problem Statement: Given a non-negative integer {0,1,2….}, find the sum of all its digit using recursion. Example: Input: 21212 Output:8 Input: 993311 Output: 26 Input: 12131 Output:8 In this article, we will see how we can find the sum of digits of a number using recursion. The most important prerequisite for recursion is – the…
https://thecodingbot.com/sum-of-digits-of-a-number-using-recursion/
The Coding Bot
Sum of digits of a number using Recursion - The Coding Bot
In this article, we'll find the sum of digits of a number using recursion, we'll also discuss the time and space complexity of the algorithm.
Python’s built-in divmod() with examples
Python has many built-in functions. In this article, we will talk about one such function and that function is divmod(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Contents Overviewdivmod() – Syntax,…
https://thecodingbot.com/pythons-built-in-divmod-with-examples/
Python has many built-in functions. In this article, we will talk about one such function and that function is divmod(). We will talk about its syntax, where is it used, what parameters it takes and what value it returns. After the discussion, we will see some examples for better understanding. Table of Contents Overviewdivmod() – Syntax,…
https://thecodingbot.com/pythons-built-in-divmod-with-examples/
The Coding Bot
Python's built-in divmod() with examples - The Coding Bot
In this article, we will talk about the built-in function divmod(), we will talk about its syntax, parameters, the return value and some examples
Python’s set() function with examples
Table of Contents Overviewset() – Syntax, Parameters and Return Value.Examples – set() with string, tuple, list, buffer and dictionaryExamples – set() with an iterator objectSuggested Reading Set in mathematics is a well-defined collection of distinct objects which are often called as elements or the members. There’s a dedicated datastructure for sets in almost every advanced…
https://thecodingbot.com/pythons-set-function-with-examples/
Table of Contents Overviewset() – Syntax, Parameters and Return Value.Examples – set() with string, tuple, list, buffer and dictionaryExamples – set() with an iterator objectSuggested Reading Set in mathematics is a well-defined collection of distinct objects which are often called as elements or the members. There’s a dedicated datastructure for sets in almost every advanced…
https://thecodingbot.com/pythons-set-function-with-examples/
The Coding Bot
Python's set() function with examples - The Coding Bot
In python, set() is a built-in method which also happens to be a constructor. In this article, we will discuss about set() in detail.
How to print to stderr in Python?
Table of Contents OverviewBasics – Brief discussion on stderr and stdoutImplementationFlowchart of the process print() is a built-in method in python which by default writes to the python’s stdout file object. However, we can redefine the print() function to redirect the output to stderr rather than stdout. print() has a kwarg called file where we…
https://thecodingbot.com/how-to-print-to-stderr-in-python/
Table of Contents OverviewBasics – Brief discussion on stderr and stdoutImplementationFlowchart of the process print() is a built-in method in python which by default writes to the python’s stdout file object. However, we can redefine the print() function to redirect the output to stderr rather than stdout. print() has a kwarg called file where we…
https://thecodingbot.com/how-to-print-to-stderr-in-python/
The Coding Bot
How to print to stderr in Python? - The Coding Bot
In this article, we'll see how we can print to stderr using the print() function. We'll also see the difference between stdout and stderr
Python’s built-in print() function with examples
Table of Contents Overviewprint() – Syntax, Parameters and Return ValueExamples using print()print() with no argumentsprinting to standard outputprint() with no argumentprint() with a string, tuple, dictionary, list and setprint() with multiple argumentsprint() with sep argumentprint() with end argumentPrinting to a text streamprinting to stderrprinting to a custom fileSuggested Reading Almost everyone starts their Python journey…
https://thecodingbot.com/pythons-built-in-print-function-with-examples/
Table of Contents Overviewprint() – Syntax, Parameters and Return ValueExamples using print()print() with no argumentsprinting to standard outputprint() with no argumentprint() with a string, tuple, dictionary, list and setprint() with multiple argumentsprint() with sep argumentprint() with end argumentPrinting to a text streamprinting to stderrprinting to a custom fileSuggested Reading Almost everyone starts their Python journey…
https://thecodingbot.com/pythons-built-in-print-function-with-examples/
The Coding Bot
Python's built-in print() function with examples - The Coding Bot
In this tutorial, we will talk learn everything about python's built-in print() function. We will also see sufficient examples using it
Python’s isdisjoint() method with examples
Python has many built-in methods which are made to ease several common tasks, one such method is isjoint(). It is a set based built-in function, which means it is only applicable to the set data structure. Table of Contents Overviewisdisjoint() – Syntax, Parameters and Return ValueExamples using isdisjoint()isdisjoint() with str, list, tuples and setisdisjoint() with…
https://thecodingbot.com/pythons-isdisjoint-method-with-examples/
Python has many built-in methods which are made to ease several common tasks, one such method is isjoint(). It is a set based built-in function, which means it is only applicable to the set data structure. Table of Contents Overviewisdisjoint() – Syntax, Parameters and Return ValueExamples using isdisjoint()isdisjoint() with str, list, tuples and setisdisjoint() with…
https://thecodingbot.com/pythons-isdisjoint-method-with-examples/
The Coding Bot
Python's isdisjoint() method with examples - The Coding Bot
In this article, we'll discuss about python's built-in isdisjoint() method with examples. It is set based method which means it is applicable to only set data structures