Back

Code Challenge: Height Converter

Difficulty  

divider

Objective

Convert a height given in inches into feet and inches. Someone 70 inches tall is 5 feet 10 inches.

This is the challenge that makes // and % from Activity 1.4 genuinely useful. Floor division gives you the whole feet; modulus gives you the inches left over.

Skills to Practice

  • Prompting a user for input
  • Converting input to the correct data type
  • Performing arithmetic
  • Using floor division and modulus together
  • Formatting custom output using variables

Tasks

  • Create a new Python program named cc-height-converter.
  • Prompt the user for their height in inches.
  • Work out the whole number of feet, and the leftover inches.
  • Display the result in the form X feet Y inches.

Sample Output

Sample Output
Enter your height in inches: 70 [Enter]
Your height is 5 feet 10 inches.

Commence Challenge