29 September 2020

Python Tips, Tricks, Hacks and Idioms

Be the best Python programmer you can be. Your guide to writing cleaner, quicker and neater Python code. Plus some handy Python tricks!

Getting started with Python If you are new to Python, chances are that you will find this post quite useful. Here you will learn about some common Python starter tips and tricks that will enable you to write simple and efficient code. Python version 3.5.2 was used to create this tutorial. List initialization Lists are […]

Prerequisites To learn about Linear and Binary search, you’ll need to have a good understanding of: Python 3 Basic Python data structure concepts – lists Introduction Often we will have to find an element from a given data structure like lists, linked lists or binary trees. An efficient searching technique saves a great amount of […]

Prerequisites To learn about the Queue data structure, you should first have a good understanding of the following: Python 3 Basic data structure concepts like List (Click here to refresh List concepts) OOP concepts Introduction This tutorial will help you understand a Queue data structure and how to implement it. These concepts are often tested […]

Prerequisites In order to understand this stack tutorial, you’ll need to learn the Stack data structure which requires the following: Python 3 Basic data structure concepts like List (Click here to refresh List concepts) OOP concepts What is a Stack? Howdy! If you are reading this article, you are about to learn one of the […]

Prerequisites Knowledge of  the following is required: Python 3 Basic Python data structures like dictionary File operations in Python Introduction Literally, the term pickle means storing something in a saline solution. Only here, instead of vegetables its objects. Not everything in life can be seen as 0s and 1s (gosh! philosophy), but pickling helps us […]

You might remember this from math class, but if even if you don’t, it should still be pretty easy to follow along. We’ve already gone over matrices and how to use them in Python, and today we’re going to talk about how you can super quickly and easy transpose a matrix. When you transpose a […]

Just like in any other OOP languages, Python uses comparison operators to compare values. These are often called Boolean operators, because the word Boolean indicates that the result of using the comparison operator is a Boolean value: true or false. What follows is a list of the Boolean values that can be used in Python when […]

It’s pretty easy to use Python to perform calculations and arithmetic. One cool type of arithmetic that Python can perform is to calculate the remainder of one number divided by another. To do this, you need to use the modulo operator (otherwise known as the percentage sign: %). When you place a modulo in between two […]

In Python, the pass statement, much like a comment, is considered a null statement, meaning that it doesn’t result in any Python operations. The only difference between a comment and a pass statement is that while a comment is completely ignored by the interpreter, the pass statement is not (but, like a comment statement, nothing […]

In Python, modules are Python files containing Python functions to be implemented in your code. You’ll know a file is a module because of its .py extension. We can import modules easily using the import command, like this: import mymodule The example above will work when theres a file called mymodule.py from which functions can […]

  • «
  • 1 (current)
  • 2
  • 3
  • »


Leave a Reply

Your email address will not be published. Required fields are marked *