Tagged: elif

Everything tagged "elif", newest first.

Coding Practice ·

Python Coding Exercise #55: The Longer String

A beginner Python exercise on len() and if, elif and else — compare the lengths of two strings and print whichever is longer, or a message when they are equally long.

Coding Practice ·

Python Coding Exercise #42: Gift Tax Calculator

A beginner Python exercise on if, elif and else with several ranges — calculate gift tax from a table of brackets, and learn to turn a complicated table into a simple reference table before writing any code.

Coding Practice ·

Python Coding Exercise #39: FizzBuzz

A beginner Python exercise on the remainder operator and the and operator — print Fizz, Buzz or FizzBuzz depending on whether a number is divisible by 3, 5 or both, and see why the order of the conditions matters.

Coding Practice ·

Python Coding Exercise #38: Grades and Points

A beginner Python exercise on if, elif and else with ranges — turn a table of point boundaries into a grade, handle impossible values, and see two ways to write the conditions.

Coding Practice ·

Python Coding Exercise #37: Nephews

A beginner Python exercise on the or operator — recognise a name that matches any one of several options, avoid the classic mistake of writing or "Dewey", and meet the shorter in operator.

Coding Practice ·

Python Coding Exercise #36: Age Check

A beginner Python exercise on if, elif and else with three outcomes — respond to an age that is normal, too young, or impossible — and learn why the order of the conditions matters.

Coding Practice ·

Python Coding Exercise #35: Alphabetically Last

A beginner Python exercise on comparing strings — find which of two words comes last in alphabetical order, and learn how Python compares text, including the effect of uppercase letters.

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.

All tags