Tagged: conditionals

Everything tagged "conditionals", newest first.

Coding Practice ·

Python Coding Exercise #34: The Elder

A beginner Python exercise on if, elif and else — read the names and ages of two people, print the name of the elder, and avoid the mistakes of comparing the wrong variables or comparing ages as text.

Coding Practice ·

Python Coding Exercise #33: Greater Than or Equal To

A beginner Python exercise on if, elif and else — compare two numbers, print the greater one, and handle the case where they are equal.

Coding Practice ·

Python Coding Exercise #32: Age of Maturity

A beginner Python exercise on if and else — decide whether someone is of age using 18 as the limit, and see why the boundary value 18 is the number to test.

Coding Practice ·

Python Coding Exercise #30: Number of Characters

A beginner Python exercise on the len() function and if statements — count the characters in a word and print the count only when the word has more than one character.

Coding Practice ·

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.

Coding Practice ·

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.

Coding Practice ·

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.

Coding Practice ·

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.

Coding Practice ·

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.

Coding Practice ·

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.

All tags