Calculate and displays the sum of all numbers from 1 to 20
Bug?
Do you want to display a cumulative sum every time the loop executes? That's what you do now. If not - if you want to only display the final sum - you need to de-indent your print.
Sum
You can do the whole sum using the actual sum function, like this:
total = sum(range(1, n + 1))

Note that you should not call a variable sum, because that shadows the built-in sum function.
Calculating the sum
This doesn't actually need a loop or a call to sum at all. Math will tell you that the entire sum will evaluate to \$n(n + 1)/2\$; an example of equivalence:
$$
\begin{align}
1 + 2 &amp;= 3\\
\frac{2 * 3}{2} &amp;= 3
\end{align}
$$