Back

Code Challenge: Miles to Kilometers

Difficulty  

divider

Objective

Convert a distance from miles to kilometers based on user input.

Skills to Practice

  • Prompting a user for input
  • Saving user input to variables
  • Converting input to the correct data type
  • Performing arithmetic calculations
  • Formatting custom output using variables

Tasks

  • Create a new Python program named cc-miles-to-kilometers.
  • Prompt the user to enter a distance in miles.
  • Convert that value to kilometers. Formula: Km = Mi × 1.609
  • Optionally, round the answer to two decimal places.
  • Display the result in a clear, formatted way.

Sample Output

Sample Output
--- Miles to Kilometers Calculator ---
Enter the distance in miles: 12.5 [Enter]
12.5 miles is equal to 20.11 kilometers

Commence Challenge