Back

Code Challenge: Display Clock

Difficulty  

divider

Objective

Ask the user for an hour, a minute, and whether it is AM or PM.

Then format and display the time in a clear, readable way — just like a digital clock.

Skills to Practice

  • Prompting a user for input
  • Storing input in variables
  • Formatting text output

Tasks

  • Create a new Python program named cc-display-clock.
  • Ask the user to enter the hours.
  • Ask the user to enter the minutes.
  • Ask the user to enter AM or PM.
  • Display the formatted time on one line, in the shape a real clock would show it.

Sample Output

Sample Output
Enter the hours value: 9 [Enter]
Enter the minutes value: 30 [Enter]
Enter AM or PM: AM [Enter]
Time: 9:30 AM

Commence Challenge