Skip to content
Related Articles

Related Articles

Create digital clock using Python-Turtle

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Expert
  • Last Updated : 02 Jul, 2021

Prerequisites: Turtle Programming in Python
Turtle is a special feature of Python. Using Turtle, we can easily draw on a drawing board. First, we import the turtle module. Then create a window, next we create a turtle object and using the turtle methods we can draw in the drawing board.
Installation: To install this module type the below command in the terminal. 

pip install turtle

Note: To create a clock we will use the ‘time’ and ‘DateTime’ module of Python also, To install time use the following command:

Below is the implementation. 


import time
import datetime as dt
import turtle
# create a turtle to display time
t = turtle.Turtle()
# create a turtle to create rectangle box
t1 = turtle.Turtle()
# create screen
s = turtle.Screen()
# set background color of the screen
# obtain current hour, minute and second
# from the system
sec =
min =
hr =
# set the position of turtle
t1.goto(-20, 0)
# create rectangular box
for i in range(2):
# hide the turtle
while True:
    # display the time
            font =("Arial Narrow", 35, "bold"))
    sec+= 1
    if sec == 60:
        sec = 0
        min+= 1
    if min == 60:
        min = 0
        hr+= 1
    if hr == 13:
        hr = 1



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!