Coding Practice

Sharing the programming exercises I practice while learning to code.

Beginner · Python ·

Python Coding Exercise #52: Powers of Two and Powers of Base n

Two beginner Python exercises on a while loop that multiplies — print the powers of two up to a limit, then change the program so the user chooses the base.

Beginner · Python ·

Python Coding Exercise #51: Even Numbers, Countdown and Counting Up

Three beginner Python exercises on while loops with a condition instead of while True — print the even numbers up to 30, fix a broken countdown, and print every number below a limit.

Beginner · Python ·

Python Coding Exercise #50: Working with Numbers

A beginner Python exercise on collecting statistics in a loop — read numbers until the user types zero, then print the count, the sum, the mean, and how many numbers were positive and negative.

Beginner · Python ·

Python Coding Exercise #49: Story

A beginner Python exercise on building a string inside a loop — collect words from the user until they type "end" or repeat the previous word, and learn how to remember the previous value.

Beginner · Python ·

Python Coding Exercise #48: The Next Leap Year

A beginner Python exercise on searching with a while loop — start from the year after the one entered, test each year against the leap year rule, and stop at the first one that fits.

Beginner · Python ·

Python Coding Exercise #47: PIN and Number of Attempts

A beginner Python exercise on loops and counters — keep asking for a PIN until it is correct, count the attempts, and print a different message when it takes only one try.

Beginner · Python ·

Python Coding Exercise #46: Repeat Password

A beginner Python exercise on loops and input — ask for a password once, then keep asking the user to repeat it until it matches, and learn which lines belong inside the loop and which outside.

Beginner · Python ·

Python Coding Exercise #45: Fix the Code: Countdown

A beginner Python debugging exercise on while True and break — a countdown stops after the first number because the break condition is the wrong way round, and the fix is one symbol.

Beginner · Python ·

Python Coding Exercise #44: Input Validation

A beginner Python exercise on loops and input validation — keep asking for numbers, reject negative ones, print the square root of positive ones, and stop when the user types zero.

Beginner · Python ·

Python Coding Exercise #43: Shall We Continue?

A beginner Python exercise on your first while loop — repeat a message until the user types "no", and learn how while True and break work together.