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…

I’ve collected a list of useful tips and “tricks” you can use to write professional Swift code.

I hope you enjoy it.

Ternary operators allow us to make `if...else`

statements shorter.

The syntax is:

**condition** ? **true** : **false**

For example, let’s compress this if-else expression:

letmoney = 100…

Here is the link to the complete code for the animated gradient ViewController.swift. To learn how it’s done, stick around.

A gradient is a powerful effect. Choosing colors that look good together is essential to make it stand out. You may find color samples in uiGradients useful.

I use these…

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…

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.

To find the inverse function, follow these four steps:

- Write the equation as a linear equation (swap
`f(x)`

with`y`

). - Swap variables
`x`

and`y`

. - Solve for
`y`

. - Apply the inverse notation (replace
`y`

with`f^(-1)(x)`

).

Find the inverse function of

To calculate the volume of a cube with a side length `a`

, use the following formula:

**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.

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!

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

.

The reason…

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…

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.