How to Find Path Where Python is Installed on Windows?

Windows normally installs Python on one of the two locations: C:\Python39 C:\Users\YourUser\AppData\Local\Programs\Python\Python39 For me, it’s the latter. For you, it may be different—this article shows you how to check for yourself! πŸ™‚ For your convenience, I’ve made a short gif that shows how I rushed through the code on my Windows machine: Before you start, … Read more

Python Method Resolution Order (MRO)

Today we’re going to look at the Python Method Resolution Order or MRO for short. If you’ve been following the tutorials on Python classes and inheritance, and you’ve been practicing in code, you’ll understand that once the hierarchy of classes moves into multiple inheritances, you may return strange results or end up with incomprehensible errors. … Read more

How to Iterate Over a Dictionary in Python?

[toc] Introduction A Python dictionary stores data in the form of key-value pairs. A dictionary in Python is ordered, mutable and does not allow duplicates. The keys in the dictionary are paired with the values by using a colon (:) while the commas fill in as a separator for the pairs. The values can be the same but … Read more

Python Or Operator

Python’s or operator performs the logical OR operation that returns True if at least one of the operands evaluates to True. The operator performs an optimization called short-circuiting, so if the first operand evaluates to True, it returns the first right away without further evaluating the second, and if the first operand evaluates to False, … Read more

How To Add New Keys To a Python Dictionary?

Introduction Before diving into the solutions to our question, here’s a quick recap of Python dictionaries. In Python, a dictionary is a collection of objects. A Python dictionary stores data in the form of key-value pairs. A dictionary in Python is ordered, changeable and does not allow duplicates. The keys in the dictionary are paired … Read more

How to Find the Index of a List Element in Python?

Introduction Lists are the built-in data type in Python used to store items in an ordered sequence. You will definitely use lists in most of your projects if you are programming in Python. So take your time and invest a good hour or so to study this guide carefully. Note: In Python, list elements start … Read more

Python And Operator

Python’s and operator performs the logical AND operation that returns True if both operands evaluate to True. The operator performs an optimization called short-circuiting, so if the first operand evaluates to True, it returns the second operand; and if the first operand evaluates to False, it returns False without further evaluating the second operand. As … Read more

[Google Interview] Rotate Matrix

[toc] ?️ Asked in: Google, Facebook, Amazon Are you terrified of being asked this question in an interview? Don’t worry! You are not alone. Many people found it intimidating. Unfortunately, the probability of seeing it at least once is quite high if you are undergoing a lot of interviews. Many interviewee’s have claimed that they … Read more

Python Exponent – 4 Operators Every Coder Must Know

Python has four ways to calculate the n-th power (exponent) of x so that xⁿ=x*x*…*x that multiplies the base x with itself, and repeating this n-times. Method 1: Use the double-asterisk operator such as in x**n. Method 2: Use the built-in pow() function such as in pow(x, n). Method 3: Import the math library and … Read more