Python

two guys arm wrestling at a bar in black and white

Mutable vs Immutable objects in Python

There are two types of objects in Python, Mutable and immutable objects. Mutable objects are more flexible in that these objects can be changed in place. Immutable objects are more static and cannot be changed without allocating a new object of the new type or with the new value. In some languages, almost all variables are immutable. In other languages most objects are mutable, and you can be fairly liberal with changing the objects whenever you want. Today we will discuss mutable vs immutable objects.  Read more […]

Read More

Python Numbers

Today we will discuss the different kinds of number varaibles in Python. How to interact with them, and what they are used for. There are four kinds of numbers in the python language: Int Long Float Complex Integers Integers are the basic kinds of numbers in any programming language. Integers are whole numbers, which means they do not have a decimal point. They can be either positive or negative. In Python 2 there is a maximum int size of 9223372036854775807. You can see this Read more […]


Working with DateTime objects in Python

When you read a date or time from a text file, user input, or a database, you are likely to get the date information as a string. It is helpful to convert the string to a datetime object since it will allow you to do more advanced functions. In todays article I will discuss and show examples of datetime objects in python. Specifically, I will show how to convert a string to a datetime, how to compare and reformat datetime variables, how to work with timezones, and how to extract specific bits of Read more […]


Using TinyDB with Python

When writing your python code, you will undoubtedly find yourself in the situation where you need to store some structured data. You could just write the data to a file, but that data might take a bit of work to parse later on. Setting up a MySQL server takes a bit of work, and might be overkill for what you are trying to do. Today we will discuss how to use TinyDB in your python application to store structured data in JSON format.  And then easily retrieve that data without any fancy coding gymnastics What Read more […]


Python Math Operators

Understanding the Python Math Operators is very important. You use these operators throughout the Python language whether it be concatenating strings, doing basic algebra, complex calculus, or delving into data science. In this article, we will cover the basics of doing math with python including how to do multiplication, division, addition substraction, exponents, and orders of operation. What is an Operator? A math operator is a symbol that defines a specific kind of logic. For example, if Read more […]


Python String Operations

A string is one of the many datatypes in Python. Some of the other common ones are objects, lists, integers, and dates. At its core, a string is really a list/array of characters. Today we will be Python String Operations. We will cover how to Concatenate, Tokenize, Manipulate, Search strings, and create string templates. Concatenate Concatenating strings is just taking two separate strings and gluing them together. In Python, it is extremely easy. You simply use the ‘+’ symbol to add the strings Read more […]


Python Virtual Environment

By defualt Pyton only gives you a single environment for your whole system.  This means when you install Python, or a package using Pip, you are installing that version of python or that version of the python package for the entire system.  And all scripts you run will interact with that same version of python or package. However, there are benefits to having a different python environment for each python application. Each application may have different dependencies. And may have compatibility Read more […]


Python Pandas Tutorial

Pandas is useful for doing data analysis in Python. Today we will discuss how to install Pandas, some of the basic concepts of Pandas Dataframes, then some of the common Pandas use cases. What is Pandas? Pandas is a Python library for doing data analysis. Typically you will use it for working with 1-dimentional series data, or 2-dimentional data called data frames. This might include: Tabular data like SQL tables or Excel spreadsheets Ordered and unordered time series data. Matrix Read more […]


Creating a webpage using Python and Flask

Did you know you can host a webpage using nothing but Python code? You don’t have to use things like IIS or Apache. While you may not get all of the same features. When you are trying to write a simple application. Or if you want to host an API, this route is an option for you. In this article, I will describe how to create a basic webpage using Python and Flask.PrerequisitesTo follow this tutorial, you need the following three prerequisites: Intall Pyhon 3 Install Pip Install Flask To fulfill Read more […]


Error Handling in Python using With and Try

In this article we will discuss error handling using Python With Statements Try/Except/Finally statements, show how to use these in combination, and compare how it works to try/catch code blocks in other languages.What is error handling?Error handling is when you put in some extra code to tell your script what to do when things don’t go totally to plan. Perhps you try to open a file that isn’t there. Or perhaps a user puts in unexpected input.Without any error handling, your program or script Read more […]