Python Tips and Tricks
Be the best Python programmer you can be. Your guide to writing cleaner, quicker and neater Python code. Plus some handy Python tricks!
Quick Tip: Using Python’s Comparison Operators
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 […]
Read MoreTop 5 Free Python Resources for Beginners
Learning Python as a beginner can be a little overwhelming. Where do you start? How do you know you’re getting the best possible information? What do you do once you’ve gotten down the basics? If you’ve recently found yourself asking any of these questions, you’ve come to the right place. In this post, we’ve compiled a […]
Read MoreUsing Python to Check for Odd or Even Numbers
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 […]
Read MoreUsing Python’s Pass Statement
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 […]
Read MorePython Basics: What Are Modules?
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 […]
Read MorePython’s help() Function
In Python, help() is a super useful built-in function that can be used to return the Python documentation of a particular object, method, attributes, etc. This is such a helpful tool for Python beginners to know that many of them are probably unaware of. All you need to do is pass the object or whatever […]
Read MoreUsing the Python Package Index
The Python Package Index (PyPI) is a repository of software created for the Python language. If you’re looking for a package or a module, this is the place to find one. Any of the packages can be easily installed using PIP from the command line. At PyPI, you can download packages OR you can post them, if […]
Read MoreQuick Tip: Where to Report Your Python Bugs
Python’s Bug Tracker is the official page to report any and all Python bugs you may encounter. While it is a good place to go if you think you’ve found a legitimate bug, it’s also a great place to meet other Python developers who may be able to help you (or validate your findings). Using the […]
Read MoreHow to Use Print for More Efficient Code
Here’s a quick tip that will help make your Python code way more efficient if you’re not already taking advantage of it. If you want to print all the values in a list separated by a comma, there are a couple different ways you can go about doing this: there are complicated ways, and then […]
Read MoreQuick Tip: Reversing Strings in Python
There is no built in function in Python for reversing a string, but that doesn’t mean it can’t be done. To reverse a string in Python, a little bit of extended slice syntax needs to be used, so you’re going to have to add something to your code that looks like this: [::-1]. Here’s what […]
Read More