Python dictionary’s keys() method with examples
Table of Contents Overviewdictionary.keys() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.keys()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-keys-method-with-examples/
Table of Contents Overviewdictionary.keys() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.keys()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-keys-method-with-examples/
The Coding Bot
Python dictionary's keys() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in keys() method. We will also see what dictionary view objects are,in detail..
Time Complexity analysis of Python dictionary’s get() method
We have already discussed Python dictionary’s get() method in great detail here(you might want to go and check that first). In this tutorial, we shall only focus on the runtime cost of the method. Before moving forward, let’s briefly see whatget() function does. get() dictionary.get(key,default_value) gets the value associated with the key key in the dictionary. If the key isn’t present…
https://thecodingbot.com/time-complexity-analysis-of-python-dictionarys-get-method/
We have already discussed Python dictionary’s get() method in great detail here(you might want to go and check that first). In this tutorial, we shall only focus on the runtime cost of the method. Before moving forward, let’s briefly see whatget() function does. get() dictionary.get(key,default_value) gets the value associated with the key key in the dictionary. If the key isn’t present…
https://thecodingbot.com/time-complexity-analysis-of-python-dictionarys-get-method/
The Coding Bot
Time Complexity analysis of Python dictionary's get() method - The Coding Bot
In this tutorial, we'll discuss the time complexity of dictionary's get() method. We'll also what is a collision in a Hashmap with example
LeetCode – 387. First Unique Character in a String
Problem Statement: Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contains only lowercase letters. Solution Probably the best approach to solve this problem is by traversing the string and using a…
https://thecodingbot.com/leetcode-387-first-unique-character-in-a-string/
Problem Statement: Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contains only lowercase letters. Solution Probably the best approach to solve this problem is by traversing the string and using a…
https://thecodingbot.com/leetcode-387-first-unique-character-in-a-string/
The Coding Bot
LeetCode - 387. First Unique Character in a String - The Coding Bot
In this tutorial, we will see how we can solve leetcode problem 387 - "First Unique Character in a String"
LeetCode – 69. Sqrt(x)
Problem Statement Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 ----------- Example 2: Input: 8 Output: 2 Explanation: The…
https://thecodingbot.com/leetcode-69-sqrtx/
Problem Statement Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 ----------- Example 2: Input: 8 Output: 2 Explanation: The…
https://thecodingbot.com/leetcode-69-sqrtx/
The Coding Bot
LeetCode - 69. Sqrt(x) - The Coding Bot
In this tutorial, we'll see how we can solve leetcode problem 69 sqrt(x). This problem can be solved using binary search algorithm
Find and Replace in Vim/Vi (covering different scenarios)
Table of Contents Find and replace in the whole file Command and ExplanationFind and replace in certain line in the fileCommand and Explanation Find and replace the words in a range of linesCommand and Explanation Find and Replace is a pretty useful feature which can save your time a lot. Vim/Vi comes with the find and…
https://thecodingbot.com/find-and-replace-in-vim-vi-covering-different-scenarios/
Table of Contents Find and replace in the whole file Command and ExplanationFind and replace in certain line in the fileCommand and Explanation Find and replace the words in a range of linesCommand and Explanation Find and Replace is a pretty useful feature which can save your time a lot. Vim/Vi comes with the find and…
https://thecodingbot.com/find-and-replace-in-vim-vi-covering-different-scenarios/
The Coding Bot
Find and Replace in Vim/Vi (covering different scenarios) - The Coding Bot
In this tutorial, we will see how we can find and replace in Vim/Vi editor. This is a complete tutorial covering different scenarios.
LeetCode – 7. Reverse Integer
Problem Statement Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that…
https://thecodingbot.com/leetcode-7-reverse-integer/
Problem Statement Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that…
https://thecodingbot.com/leetcode-7-reverse-integer/
The Coding Bot
LeetCode - 7. Reverse Integer - The Coding Bot
In this article, we will see how we can solve famous interview problem from leetcode. The problem name is "LeetCode - 7. Reverse Integer"
LeetCode – 26. Remove Duplicates from Sorted Array
Problem Statement Given a sorted array nums, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return…
https://thecodingbot.com/leetcode-26-remove-duplicates-from-sorted-array/
Problem Statement Given a sorted array nums, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return…
https://thecodingbot.com/leetcode-26-remove-duplicates-from-sorted-array/
The Coding Bot
LeetCode - 26. Remove Duplicates from Sorted Array - The Coding Bot
In this article, we'll see how we can solve "LeetCode 26 Remove Duplicates from Sorted Array". We'll also see the time-space complexity of the problem.
Python dictionary’s values() method with examples
Table of Contents Overviewdictionary.values() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.values()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-values-method-with-examples/
Table of Contents Overviewdictionary.values() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.values()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-values-method-with-examples/
The Coding Bot
Python dictionary’s values() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in values() method. We will also see what dictionary view objects are,in detail..
Python dictionary’s pop() method with examples
Table of Contents Overviewdictionary.pop() – Syntax, Parameters and Return ValueExamples using pop()Example 1 – When the key is present in the dictionaryExample 2 – When the key is not present but the default is passedExample 3 – When the key is not present and no default is passedReplicating pop() with try and catch block and…
https://thecodingbot.com/python-dictionarys-pop-method-with-examples/
Table of Contents Overviewdictionary.pop() – Syntax, Parameters and Return ValueExamples using pop()Example 1 – When the key is present in the dictionaryExample 2 – When the key is not present but the default is passedExample 3 – When the key is not present and no default is passedReplicating pop() with try and catch block and…
https://thecodingbot.com/python-dictionarys-pop-method-with-examples/
The Coding Bot
Python dictionary's pop() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in pop() method, we'll also see some examples demonstrating the usage of the function
Python dictionary’s popitem() method with examples
Table of Contents Overviewpopitem() – Syntax, Parameters and the Return ValueExamples using popitem() methodExample 1 – Completely deleting all the elements from the dictionary using popitem()Example 2 – When the dictionary is empty or run out of elementsSuggested Reading Sometimes we need to iterate through a dictionary in Python and delete its items sequentially. To…
https://thecodingbot.com/python-dictionarys-popitem-method-with-examples/
Table of Contents Overviewpopitem() – Syntax, Parameters and the Return ValueExamples using popitem() methodExample 1 – Completely deleting all the elements from the dictionary using popitem()Example 2 – When the dictionary is empty or run out of elementsSuggested Reading Sometimes we need to iterate through a dictionary in Python and delete its items sequentially. To…
https://thecodingbot.com/python-dictionarys-popitem-method-with-examples/
The Coding Bot
Python dictionary's popitem() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in popitem() method with examples. It is used to remove elements from dictionary in LIFO order.
Python dictionary’s setdefault() method with examples
Table of Contents Overviewsetdefault() – Syntax, Parameters and the Return ValueExamples using setdefault() methodExample 1 – When the key is present in the dictionaryExample 2 – When the key isn’t present in the dictionary but a default value is passedExample 3 – When the key isn’t present and no default value is passed eitherReplicating setdefault()…
https://thecodingbot.com/python-dictionarys-setdefault-method-with-examples/
Table of Contents Overviewsetdefault() – Syntax, Parameters and the Return ValueExamples using setdefault() methodExample 1 – When the key is present in the dictionaryExample 2 – When the key isn’t present in the dictionary but a default value is passedExample 3 – When the key isn’t present and no default value is passed eitherReplicating setdefault()…
https://thecodingbot.com/python-dictionarys-setdefault-method-with-examples/
The Coding Bot
Python dictionary's setdefault() method with examples - The Coding Bot
In this tutorial, we'll see python dictionary's setdefault() method which is a combination of both get() and set() methods. We'll also see some illustrations.
A very detailed tutorial on autocompletion with Django and jQuery
Have you ever wondered how you type few in the search bar and it starts giving you suggestions? This feature has always been in my todo list and I finally implemented it a few days in my own website. This tutorial uses Jquery and Django for most of the part. So, yes, it’s a prerequisite. At least you should have a working knowledge.…
https://thecodingbot.com/a-very-detailed-tutorial-on-autocompletion-with-django-and-jquery/
Have you ever wondered how you type few in the search bar and it starts giving you suggestions? This feature has always been in my todo list and I finally implemented it a few days in my own website. This tutorial uses Jquery and Django for most of the part. So, yes, it’s a prerequisite. At least you should have a working knowledge.…
https://thecodingbot.com/a-very-detailed-tutorial-on-autocompletion-with-django-and-jquery/
The Coding Bot
A very detailed tutorial on autocompletion with Django and jQuery - The Coding Bot
In this tutorial, we will see how to implement autocomplete feature in django framework, we will also see how we can add onclick redirect functionality.
How to get Weekday name from Datetimefield in Django jinja2 templating
Overview Django uses a pretty powerful template engine known as Jinja. Not just for the Django, it has become a pretty famous template engine for overall Python. Instagram and Firefox are one of the many websites that use Jinja2. It is a treat for MVC/MVT based frameworks as it helps to differentiate frontend from the backend. Getting…
https://thecodingbot.com/how-to-get-weekday-name-from-datetimefield-in-django-jinja2-templating/
Overview Django uses a pretty powerful template engine known as Jinja. Not just for the Django, it has become a pretty famous template engine for overall Python. Instagram and Firefox are one of the many websites that use Jinja2. It is a treat for MVC/MVT based frameworks as it helps to differentiate frontend from the backend. Getting…
https://thecodingbot.com/how-to-get-weekday-name-from-datetimefield-in-django-jinja2-templating/
The Coding Bot
How to get Weekday name from Datetimefield in Django jinja2 templating - The Coding Bot
In this tutorial, we will see how we can get the weekday name from datetimefield in Django Jinja2 templating...
How do we filter rows of a pandas Dataframe by a column value
Overview Problem Statement: Given a Dataframe, filter the rows of the Dataframe by a column value. Solution: There exist at least 2 ways to fetch the rows based on a column value. Here’s what our the Dataframe looks like. The dataset was quite intact and had no NULLs. We are going to filter rows based on the Date column, with some manipulations. We will fetch all the…
https://thecodingbot.com/how-do-we-filter-rows-of-a-pandas-dataframe-by-a-column-value/
Overview Problem Statement: Given a Dataframe, filter the rows of the Dataframe by a column value. Solution: There exist at least 2 ways to fetch the rows based on a column value. Here’s what our the Dataframe looks like. The dataset was quite intact and had no NULLs. We are going to filter rows based on the Date column, with some manipulations. We will fetch all the…
https://thecodingbot.com/how-do-we-filter-rows-of-a-pandas-dataframe-by-a-column-value/
The Coding Bot
How do we filter rows of a pandas Dataframe by a column value - The Coding Bot
In this tutorial, we will see how we can filter a pandas dataframe rows based on a column value using different techniques...
Python’s list append() method with examples
Overview In this tutorial, we will see Python’s sequence type list’s append() method in great detail. We will see its syntax, the parameters it takes, the value it returns, and some examples demonstrating its usage. We will also dig into the runtime cost of the operation. list.append(x) list.append(x) appends a new object/item x to the…
https://thecodingbot.com/pythons-list-append-method-with-examples/
Overview In this tutorial, we will see Python’s sequence type list’s append() method in great detail. We will see its syntax, the parameters it takes, the value it returns, and some examples demonstrating its usage. We will also dig into the runtime cost of the operation. list.append(x) list.append(x) appends a new object/item x to the…
https://thecodingbot.com/pythons-list-append-method-with-examples/
The Coding Bot
Python's list append() method with examples - The Coding Bot
In this tutorial, we will discuss about python list's built-in append() method with some examples. We will also discuss about the time complexity of the method.
What is the difference between char a and char a[1] in C/C++?
Problem Statement In C/C++, what is the difference between the statements char a and char a[1]? Solution In the statement char a , a is a variable which is used to store a character datatype in the memory. While in the statement char a[1], a is an array of type char(character) of size 1, i.e…
https://thecodingbot.com/what-is-the-difference-between-char-a-and-char-a1-in-c-c/
Problem Statement In C/C++, what is the difference between the statements char a and char a[1]? Solution In the statement char a , a is a variable which is used to store a character datatype in the memory. While in the statement char a[1], a is an array of type char(character) of size 1, i.e…
https://thecodingbot.com/what-is-the-difference-between-char-a-and-char-a1-in-c-c/
The Coding Bot
What is the difference between char a and char a[1] in C/C++? - The Coding Bot
In this tutorial, we will see the difference between char a and char a[1] in C++. We will also see an example to concrete our understanding
Program to check if a given integer is an Armstrong number or not
Problem Statement Given a positive integer, you need to check if it is an Armstrong number or not. For example: Input: 143 1^3 + 4^3 + 3^3 = 74, which is not equal to 143. Output: No Input: 407 4^3 + 0^3 + 7^3 = 407, which is equal to 407. Output: Yes What is…
https://thecodingbot.com/program-to-check-if-a-given-integer-is-an-armstrong-number-or-not/
Problem Statement Given a positive integer, you need to check if it is an Armstrong number or not. For example: Input: 143 1^3 + 4^3 + 3^3 = 74, which is not equal to 143. Output: No Input: 407 4^3 + 0^3 + 7^3 = 407, which is equal to 407. Output: Yes What is…
https://thecodingbot.com/program-to-check-if-a-given-integer-is-an-armstrong-number-or-not/
The Coding Bot
Program to check if a given integer is an Armstrong number or not - The Coding Bot
In this tutorial, we will see if a number is armstrong number or not. We will discuss the time complexity of the algorithm along with some examples.
Python program to split a given list into Even and Odd list based on the parity of the numbers
Problem Statement Given a python list consisting of both even and odd integers, based on their parity separate them into even and odd list. For example: Input: list = [1,4,6,87] Output: even_list = [4,6] , odd_list = [1,87] The problem statement is pretty clear- we have a list of integers having both even and odd…
https://thecodingbot.com/python-program-to-split-a-given-list-into-even-and-odd-list-based-on-the-parity-of-the-numbers/
Problem Statement Given a python list consisting of both even and odd integers, based on their parity separate them into even and odd list. For example: Input: list = [1,4,6,87] Output: even_list = [4,6] , odd_list = [1,87] The problem statement is pretty clear- we have a list of integers having both even and odd…
https://thecodingbot.com/python-program-to-split-a-given-list-into-even-and-odd-list-based-on-the-parity-of-the-numbers/
The Coding Bot
Python program to split a given list into Even and Odd list based on the parity of the numbers - The Coding Bot
In this tutorial, we will see a python program to split a given list into two lists - Even and Odd based on the parity of the numbers.
Vim Introduction
This entry is part 1 of 1 in the series Complete Vim Tutorial Let’s start an amazing series of tutorials on our beloved editor – The Vim editor. Started off as a free, open-source software(editor) and enhancement of already existing Unix based editor – Vi, it has made a huge fanbase over the years. It…
https://thecodingbot.com/vim-introduction/
This entry is part 1 of 1 in the series Complete Vim Tutorial Let’s start an amazing series of tutorials on our beloved editor – The Vim editor. Started off as a free, open-source software(editor) and enhancement of already existing Unix based editor – Vi, it has made a huge fanbase over the years. It…
https://thecodingbot.com/vim-introduction/
The Coding Bot
Vim Introduction - The Coding Bot
Introduction - Vim is a free, opensource text editor, and an extremely powerful one at that. It was originally launched in the year 1991..
How to print a statement in C/C++ without a semicolon(;) – Different methods
Problem Statement: We need to print a statement, say “Hello World“, without using a semicolon in C/C++. Solution: To be honest, this isn’t a serious programming question, but, it is possible that you might face this question in an interview someday. It is a kind of puzzle problem. There are many different ways to achieve…
https://thecodingbot.com/how-to-print-a-statement-in-c-c-without-a-semicolon-different-methods/
Problem Statement: We need to print a statement, say “Hello World“, without using a semicolon in C/C++. Solution: To be honest, this isn’t a serious programming question, but, it is possible that you might face this question in an interview someday. It is a kind of puzzle problem. There are many different ways to achieve…
https://thecodingbot.com/how-to-print-a-statement-in-c-c-without-a-semicolon-different-methods/
The Coding Bot
How to print a statement in C/C++ without a semicolon(;) - Different methods - The Coding Bot
In this tutorial, we will learn different ways to print a statement, say Hello World, in c/c++ without using semicolon.