# An Ultimate Guide to Writing on Medium in 2021

## Grab the keys for success on Medium

Medium is a popular blogging platform. It attracts almost 200 million unique visits monthly.

It is a wonderful place to start your writing career. You have a huge audience and a great community on your side.

This piece shows you everything you need to know about writing Medium.com. I wish…

# 10 Tips and Tricks for Writing Clean Python Code

## Impress your colleagues with clean and concise code.

Learn 10 awesome beginner-friendly Python coding “tricks” with in-depth explanations.

The following list is in no particular order.

I hope you enjoy it!

# 1. Swap Two Variables without a Third

In Python, it is possible to swap two variables without a third one:

`a = 1b = 2a, b = b, a`

## Explanation

The above “trick”…

# An Introduction to the ‘with’ Statement in Python

The `with` statement in Python helps you with resource management. It ensures no resources are accidentally left open.

The `with` statement is a replacement for commonly used `try`/`finally` error-handling statements.

A common example of using the `with` statement is opening a file.

To open and write to a file in…

# How Far Is the Horizon

## You can see a staggering 200+ miles from a commercial airplane

The distance to the horizon depends on how high you are observing it.

If you are 5'6'’, standing on the shoreline, the horizon appears 2.75 miles away from you.

In this article, you learn how to calculate the distance to the horizon with a simple formula.

# How to Find the Inverse Function

To find the inverse function, follow these four steps:

1. Write the equation as a linear equation (swap `f(x)` with `y`).
2. Swap variables `x` and `y`.
3. Solve for `y`.
4. Apply the inverse notation (replace `y` with `f^(-1)(x)`).

# Example

Find the inverse function of

# How to Calculate the Volume of a Cube

To calculate the volume of a cube with a side length `a`, use the following formula:

# How Many Quarts Are in a Gallon

There are 4 quarts in 1 gallon.

This is easy to remember. Consider the word “quart”. It refers to a quarter.

When speaking about volumes, a quart is a quarter of a gallon. In other words, it is one-fourth of a gallon—so there are four of them in a gallon.

# What Is the Resolution of 4k

The resolution for 4k is

`3840 x 2160`

This means a 4k screen has a whopping 8.3 million pixels in total. This is 36 times more than a good old 480p SD screen!

# Why Is It Called 4k?

The 4k refers to 4000. But the resolution of 4k is “only” `3840 x 2160`.

The reason…

# Python Switch Case—Comprehensive Guide

## Learn everything about structural pattern matching in Python

Python switch-case statements are here! And they are actually called match-case statements.

This means you can soon replace this type of if-else mess:

With a more compact match-case statement:

In some situations, the latter approach is better. It can make the code more readable and less repetitive.

Notice…

# Python Dictionary — A Complete Guide

## Learn everything about dictionaries in Python

Python dictionary is an unordered collection of items. Each item is a key-value pair.

Dictionaries can be used to represent labeled data.

For example, you can represent a student as a dictionary:

With dictionaries, it is easy to access, modify, and delete entries.

For example:

In this guide…

## Artturi Jalli

I’m a tech expert, entrepreneur, and software engineer from Finland. I write about programming, tech, and science. Visit my blog at www.codingem.com.

Get the Medium app