Coding Practice

Sharing the programming exercises I practice while learning to code.

Beginner · Python ·

Python Coding Exercise #22: Area and Circumference of a Circle

A beginner Python exercise on the math module — read a radius, calculate a circle's area and circumference using pi, and round the answers to two decimal places.

Beginner · Python ·

Python Coding Exercise #21: Grams to Kilograms

A beginner Python exercise on unit conversion — turn a whole number of grams into kilograms and leftover grams, then polish the output so singular and plural words and zero values read correctly.

Beginner · Python ·

Python Coding Exercise #20: What to Wear Tomorrow

A beginner Python exercise on comparison conditions — turn "over 20, 10 or 5 degrees" into the right if statements, learn how to pick between <, <=, > and >=, and practise with boundary values.

Beginner · Python ·

Python Coding Exercise #19: Loyalty Bonus

A beginner Python debugging exercise on if and else — why two separate if statements can both run when the first one changes the variable the second one checks, and how to fix it.

Beginner · Python ·

Python Coding Exercise #18: Daily Wages

A beginner Python exercise on if statements and arithmetic — calculate a day's pay from the hourly wage and hours worked, with double pay on Sundays.

Beginner · Python ·

Python Coding Exercise #17: Temperatures

A beginner Python exercise that converts Fahrenheit to Celsius and prints an extra message when the result is below zero — practice with formulas, floats and if statements.

Beginner · Python ·

Python Coding Exercise #16: Calculator

A beginner Python exercise on comparing strings with if statements — build a small calculator that adds, subtracts or multiplies two numbers depending on the operation the user types.

Beginner · Python ·

Python Coding Exercise #15: Order of Magnitude

A beginner Python exercise on separate if statements — print every "smaller than" message that applies to a number, and see why using elif here would give the wrong output.

Beginner · Python ·

Python Coding Exercise #14: Soup or No Soup

A beginner Python exercise on if/else with strings — ask for a name, skip the order for one particular customer, and work out the total cost for everyone else without floating-point surprises.

Beginner · Python ·

Python Coding Exercise #13: Simple if Statements

Two short beginner Python exercises on if statements and comparison operators — print "Orwell" only when the number is 1984, and calculate the absolute value of a number.