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
Python’s isdisjoint() method time complexity (set intersection)
We already discussed isdisjoint() in great detail here. This tutorial will only focus on the runtime complexity of the function as programmers tend to get confused about the runtime complexity a lot. Let’s quickly recall what isdisjoint() function is, and what it does. isjoint() When applied to a set x, it returns true if no element from set x is…
https://thecodingbot.com/pythons-isdisjoint-method-time-complexity-set-intersection/
We already discussed isdisjoint() in great detail here. This tutorial will only focus on the runtime complexity of the function as programmers tend to get confused about the runtime complexity a lot. Let’s quickly recall what isdisjoint() function is, and what it does. isjoint() When applied to a set x, it returns true if no element from set x is…
https://thecodingbot.com/pythons-isdisjoint-method-time-complexity-set-intersection/
The Coding Bot
Python's isdisjoint() method time complexity (set intersection) - The Coding Bot
In this post, we'll talk about the time complexity of python's built-in isdisjoint() method which internally uses set insersection algorithm.
Different ways to iterate/loop over a dictionary in Python
Table of Contents Overview – What is a dictionary?Iterating through the keysMethod 1 – Using in keywordMethod 2 – Using dict.keys()Iterating through the valuesUsing dict.values()Iterating through the key-value pairsUsing dict.items()Additional infoSuggested Reading What is a dictionary in Python? A dictionary is a collection which is unordered, mutable and indexed. Mutable here means the values can…
https://thecodingbot.com/different-ways-to-iterate-loop-over-a-dictionary-in-python/
Table of Contents Overview – What is a dictionary?Iterating through the keysMethod 1 – Using in keywordMethod 2 – Using dict.keys()Iterating through the valuesUsing dict.values()Iterating through the key-value pairsUsing dict.items()Additional infoSuggested Reading What is a dictionary in Python? A dictionary is a collection which is unordered, mutable and indexed. Mutable here means the values can…
https://thecodingbot.com/different-ways-to-iterate-loop-over-a-dictionary-in-python/
The Coding Bot
Different ways to iterate/loop over a dictionary in Python - The Coding Bot
In this tutorial, we'll see different ways to iterate over a python dictionary. We can iterate it through the keys, values and key-value pairs
std :: all_of() in C++
Table of Contents Overview std::all_of() – Syntax, Parameters and Return ValueExamples using std::all_of()Example 1 – using an array of integers with std::all_of()Example 2 – using a string with std::all_of()Time Complexity discussion std::all_of() is a built-in function under header . all_of() This C++ method returns true if all the elements in the range satisfies a certain…
https://thecodingbot.com/std-all_of-in-c/
Table of Contents Overview std::all_of() – Syntax, Parameters and Return ValueExamples using std::all_of()Example 1 – using an array of integers with std::all_of()Example 2 – using a string with std::all_of()Time Complexity discussion std::all_of() is a built-in function under header . all_of() This C++ method returns true if all the elements in the range satisfies a certain…
https://thecodingbot.com/std-all_of-in-c/
The Coding Bot
std :: all_of() in C++ - The Coding Bot
In this post, we'll discuss built-in std::all_of() in C++. The post has examples for better understanding and also discusses about time complexity of the function.
Time complexity analysis of std::all_of() in C++
We have already discussed about std::all_of() in great detail here. This tutorial explicitly focuses on the runtime cost of the function. Before moving forward let’s briefly recall what std::all_of() is, and what it does. std::all_of() is a built-in C++ function under header which returns true if all the elements in a range[start,end) satisfy a…
https://thecodingbot.com/time-complexity-analysis-of-stdall_of-in-c/
We have already discussed about std::all_of() in great detail here. This tutorial explicitly focuses on the runtime cost of the function. Before moving forward let’s briefly recall what std::all_of() is, and what it does. std::all_of() is a built-in C++ function under header which returns true if all the elements in a range[start,end) satisfy a…
https://thecodingbot.com/time-complexity-analysis-of-stdall_of-in-c/
The Coding Bot
Time complexity analysis of std::all_of() in C++ - The Coding Bot
In this article, we will explicitly focus on the time complexity of the standard template libraries's(stl) std::all_of() in C++.
std::any_of() in C++
Table of Contents Overviewstd::any_of() – Syntax, Parameters and Return ValueExamples using std::any_of()Example 1 – using an array of integers with std::any_of()Example 2 – using a string with std::any_of()Time Complexity discussionSuggested Reading std::any_of() is a built-in function under the header . any_of() This C++ method returns true if any element in the range[start,end) satisfy a certain condition(a predicate). A predicate is a function which takes…
https://thecodingbot.com/stdany_of-in-c/
Table of Contents Overviewstd::any_of() – Syntax, Parameters and Return ValueExamples using std::any_of()Example 1 – using an array of integers with std::any_of()Example 2 – using a string with std::any_of()Time Complexity discussionSuggested Reading std::any_of() is a built-in function under the header . any_of() This C++ method returns true if any element in the range[start,end) satisfy a certain condition(a predicate). A predicate is a function which takes…
https://thecodingbot.com/stdany_of-in-c/
The Coding Bot
std::any_of() in C++ - The Coding Bot
In this post, we'll discuss built-in std::any_of() in C++. The post has examples for better understanding and also discusses about time complexity of the function.
Time complexity analysis of std::any_of() in C++
We have already discussed about std::any_of() in great detail here. This tutorial explicitly focuses on the runtime cost of the function. Before moving forward let’s briefly recall what std::any_of() is, and what it does. std::any_of() is a built-in C++ function under the header which returns true if any elements in the range[start,end) satisfy a certain condition(a predicate). A predicate is a function which takes argument(s), and…
https://thecodingbot.com/time-complexity-analysis-of-stdany_of-in-c/
We have already discussed about std::any_of() in great detail here. This tutorial explicitly focuses on the runtime cost of the function. Before moving forward let’s briefly recall what std::any_of() is, and what it does. std::any_of() is a built-in C++ function under the header which returns true if any elements in the range[start,end) satisfy a certain condition(a predicate). A predicate is a function which takes argument(s), and…
https://thecodingbot.com/time-complexity-analysis-of-stdany_of-in-c/
The Coding Bot
Time complexity analysis of std::any_of() in C++ - The Coding Bot
In this article, we will explicitly focus on the time complexity of the standard template libraries's(stl) std::any_of() in C++.
std::none_of() in C++
Table of Contents Overviewstd::none_of() – Syntax, Parameters and Return ValueExamples using std::none_of()Example 1 – using an array of integers with std::none_of()Example 2 – using a string with std::none_of()Time Complexity discussionSuggested Reading std::none_of() is a built-in function under the header . none_of() This C++ method returns true if all the elements in the range[start, end) returns false for a certain condition(a predicate).…
https://thecodingbot.com/stdnone_of-in-c/
Table of Contents Overviewstd::none_of() – Syntax, Parameters and Return ValueExamples using std::none_of()Example 1 – using an array of integers with std::none_of()Example 2 – using a string with std::none_of()Time Complexity discussionSuggested Reading std::none_of() is a built-in function under the header . none_of() This C++ method returns true if all the elements in the range[start, end) returns false for a certain condition(a predicate).…
https://thecodingbot.com/stdnone_of-in-c/
The Coding Bot
std::none_of() in C++ - The Coding Bot
In this post, we'll discuss built-in std::none_of() in C++. The post has examples for better understanding and also discusses about time complexity of the function.
Python’s len() on a dictionary
len() is a built-in function in python which returns the number of items in an object. It can be used with a sequence(list, tuple, string etc) or a collection (like dictionary, set etc). However, this tutorial shall only focus its use with a dictionary. For complete tutorial on built-in len(), visit: Python’s built-in len() method…
https://thecodingbot.com/pythons-len-on-a-dictionary/
len() is a built-in function in python which returns the number of items in an object. It can be used with a sequence(list, tuple, string etc) or a collection (like dictionary, set etc). However, this tutorial shall only focus its use with a dictionary. For complete tutorial on built-in len(), visit: Python’s built-in len() method…
https://thecodingbot.com/pythons-len-on-a-dictionary/
The Coding Bot
Python's dictionary len() method - The Coding Bot
In this article, we'll show you the use of python's len() function on a simple dictionary as well as on a nested dictionary.
Python’s list() method on a dictionary
list() is a built-in python method, and also a constructor. When an iterable is passed to the method, it converts the iterable to a list. This tutorial will only focus on the use of list() function with a dictionary. For a detailed tutorial on the function list(), visit: Python’s list() with examples ( A detailed…
https://thecodingbot.com/pythons-list-method-on-a-dictionary/
list() is a built-in python method, and also a constructor. When an iterable is passed to the method, it converts the iterable to a list. This tutorial will only focus on the use of list() function with a dictionary. For a detailed tutorial on the function list(), visit: Python’s list() with examples ( A detailed…
https://thecodingbot.com/pythons-list-method-on-a-dictionary/
The Coding Bot
Python's list() method on a dictionary - The Coding Bot
In this article, we'll show you the use of python's list() function on a simple dictionary as well as on a nested dictionary.
dictionary[‘key’]: Fetching the value for a particular key in a dictionary in Python
A dictionary is basically a set of key:value pairs with a condition that no two keys are the same. Each key-value pair in the dictionary is separated by a comma. Let’s see an example of a dictionary in python, dictionary = {'apple': 2,'banana' : 5, 'carrot' : 4} Here, apple, banana and carrot are the keys; while…
https://thecodingbot.com/fetching-the-value-for-a-particular-key-in-a-dictionary-in-python/
A dictionary is basically a set of key:value pairs with a condition that no two keys are the same. Each key-value pair in the dictionary is separated by a comma. Let’s see an example of a dictionary in python, dictionary = {'apple': 2,'banana' : 5, 'carrot' : 4} Here, apple, banana and carrot are the keys; while…
https://thecodingbot.com/fetching-the-value-for-a-particular-key-in-a-dictionary-in-python/
The Coding Bot
dictionary['key']: Fetching the value for a particular key in a dictionary in Python - The Coding Bot
In this article, we'll show you the different ways you can access the value associated with a key in python dictionary.
del d[key]: Removing the key from Python dictionary
This tutorial only focuses on the use of del keyword to delete the key from a dictionary. There are other ways too which we shall discuss in a seperate post. del is a keyword in Python which is used to delete the Objects. Since everything in Python is Object, it can be used to delete the…
https://thecodingbot.com/del-dkey-removing-the-key-from-python-dictionary/
This tutorial only focuses on the use of del keyword to delete the key from a dictionary. There are other ways too which we shall discuss in a seperate post. del is a keyword in Python which is used to delete the Objects. Since everything in Python is Object, it can be used to delete the…
https://thecodingbot.com/del-dkey-removing-the-key-from-python-dictionary/
The Coding Bot
del d[key]: Removing the key from Python dictionary - The Coding Bot
In this post, we'll show you how you can delete a key from python dictionary using python's del keyword and what possible error it raises.
Check if a given key already exists in a Python dictionary (4 ways)
Table of Contents OverviewMethod 1 – Using in keywordMethod 2 – Finding the key in dict.keys()Method 3 – Using try and except block to check if the key is present in the dictionary or not.Method 4 – Iterating over dict.items() and finding the key existenceWhich is the fastest way to find key among all? What…
https://thecodingbot.com/check-if-a-given-key-already-exists-in-a-python-dictionary-4-ways/
Table of Contents OverviewMethod 1 – Using in keywordMethod 2 – Finding the key in dict.keys()Method 3 – Using try and except block to check if the key is present in the dictionary or not.Method 4 – Iterating over dict.items() and finding the key existenceWhich is the fastest way to find key among all? What…
https://thecodingbot.com/check-if-a-given-key-already-exists-in-a-python-dictionary-4-ways/
The Coding Bot
Check if a given key already exists in a Python dictionary (4 ways) - The Coding Bot
In this blog post, we'll show you different ways how you can check if the key exists in the dictionary or not.
Python dictionary items() method
Table of Contents Overviewdictionary.items() – Syntax, Parameters and Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.items() 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…
https://thecodingbot.com/python-dictionary-items-method/
Table of Contents Overviewdictionary.items() – Syntax, Parameters and Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.items() 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…
https://thecodingbot.com/python-dictionary-items-method/
The Coding Bot
Python dictionary items() method - The Coding Bot
In this article, we'll discuss python dictionary's built-in items() method. We will also see what dictionary view objects are in detail..
dictionary.clear() method in Python
Say you have a dictionary, and now, you want to get rid of its element, you want it clean. How would you do that? There are many utility methods for Python dictionary and dictionary.clear() does exactly what we want. In this post, we will discuss about clear() method for dictionaries in Python. After that, we’ll…
https://thecodingbot.com/dictionary-clear-method-in-python/
Say you have a dictionary, and now, you want to get rid of its element, you want it clean. How would you do that? There are many utility methods for Python dictionary and dictionary.clear() does exactly what we want. In this post, we will discuss about clear() method for dictionaries in Python. After that, we’ll…
https://thecodingbot.com/dictionary-clear-method-in-python/
The Coding Bot
dictionary.clear() method in Python - The Coding Bot
In this tutorial, we'll see how we can clear a dictionary in python using the built-in clear() method with some examples
Python dictionary’s get() method
Table of Contents Overviewdictionary.get() – Syntax, Parameters and the Return ValueExamples using get()Comparison between get() and subscript notation dictionary[key]Time Complexity analysis of get() Suggested Reading In this tutorial, we’ll talk about get() method from Python’s dictionary data structure. It is probably the most used method from the dictionary class. Today, we’ll see its syntax, the…
https://thecodingbot.com/python-dictionarys-get-method/
Table of Contents Overviewdictionary.get() – Syntax, Parameters and the Return ValueExamples using get()Comparison between get() and subscript notation dictionary[key]Time Complexity analysis of get() Suggested Reading In this tutorial, we’ll talk about get() method from Python’s dictionary data structure. It is probably the most used method from the dictionary class. Today, we’ll see its syntax, the…
https://thecodingbot.com/python-dictionarys-get-method/
The Coding Bot
Python dictionary's get() method - The Coding Bot
In this article, we'll talk about python dictionary's get() method. We'll see some examples and analyse the time complexity of the function