# Python How To’s

A collection of small, useful, how to’s for Python.

## How to Convert Dictionary Values to a List in Python

In Python, a dictionary is a built-in data type that can be used to store data in a way thats different from lists or arrays. Dictionaries aren’t sequences, so they can’t be indexed by a range of numbers, rather, they’re indexed by a series of keys. When learning about dictionaries, it’s helpful to think of […]

Read More## How to Use Python to Convert Miles to Kilometers

It can be so frustrating that the entire planet can’t just agree on one system of measurement, whether it relates to measuring distances, weights, temperatures, etc (for the record…same goes for which side of the road everyone drives on). If every country used the same units of measurement, then these formulas would be useless and […]

Read More## How to Multiply Matrices in Python

In Python and most other OOP programming languages, multiplying two numbers by each other is a pretty straightforward process. Where it gets a little more complicated, however, is when you try to multiply two matrices by each other. A matrix, as you may know, is basically just a nested list, or a number of lists […]

Read More## How to Check for Object Type in Python

This beginner’s Python tutorial will teach you the basics of how to check for an object type in Python. As you probably already know, different types of objects in Python. Objects can be lists, strings, integers, etc. There may be times in your career as a developer where you need to know the difference between one […]

Read More## Using Exponents in Python

By now, you probably know how to multiply and divide numbers in Python. Multiplication in Python is fairly simple and easy to do. But what about using exponents? How would you raise a number to the second power, for example? If you’re not sure, you’ll probably find the answer pretty straightforward. To raise a number […]

Read More## Multiplying and Dividing Numbers in Python

Multiplying and dividing numbers in Python is really straightforward. If you’ve ever multiplied or divided numbers in other coding languages, you’ll find the process for doing so in Python is really similar, if not pretty much exactly the same. Understanding how to multiply and divide numbers in Python is important, not because you need to […]

Read More## Using Python to Find the Largest Number out of Three

Here’s a useful snippet that will show you how to use Python to find the largest number out of any three given numbers. Basically, the snippet works by using the if…elif…else statements to compare the three numbers against each other and determine which one is the largest. Check out the snippet below to see how […]

Read More## Using Python to Check for Number in List

Today’s Python snippet is brought to you by the “in” keyword. In Python, we can use the in keyword for lots of different purposes. In terms of today’s snippet, we’re going to use it to check if a particular number is in a list. To begin, let’s say we have a list called coolNumbers. Take […]

Read More## How to Use Python’s len() Method

Python’s len() method can be used to easily find the length of a string. It’s a simple and quick way to measure the length of a string (the number of characters) without having to write a lot of code. The syntax for using the len() method is fairly straightforward, and hard to mess up — […]

Read More## How to Generate a Random Number in Python

In Python, just like in almost any other OOP language, chances are that you’ll find yourself needing to generate a random number at some point. Whether you’re just completing an exercise in algorithms to better familiarize yourself with the language, or if you’re trying to write more complex code, you can’t call yourself a Python coder […]

Read More