Skip to content
Related Articles

Related Articles

Create digital clock using Python-Turtle
  • Last Updated : 20 Aug, 2020

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 distplay 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



 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :