Python Turtle Clock

This challenge consists of using the Python turtle library and the datetime library to create a program that displays the current time as an anlogue clock.

To complete this challenge we need to do some angle calculations to understand what angles to use when displaying the small hand (hours) and the big hand (minutes).

clock

Let’s do some calculations…

 

90_degree_rotations
What angle should you use for the small hand when it is:

  • 3:00 AM
  • 6:00 AM
  • 7:00 AM
  • 3:00PM
  • 5:00PM

 

What angle should you use for the big hand when it is:

  • 3:30 AM
  • 3:45 AM
  • 3:05 AM

Task 1:

Customise your clock by adding graduations (see picture below) and complete the code to add a third hand for the seconds (between 0 and 60) using a green hand.

tutrle-clocks

Task 2:

In reality the calculation for the small hand’s angle is slightly more complex. For instance when it is 2.45PM the small hand should not be on 2 o’clock but somewhere between 2 and 3 o’clock.

This wikipedia page gives you the exact calculation that you should use to calculate the angle of the small hand.

Your task is to update the above Python code to take into consideration this new angle calculation.

ClockAngles

Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges Tagged with: , ,
One comment on “Python Turtle Clock

Our Latest Book