PWP Report
PWP Report
1.0 Rationale:
This report aims to outline the process of developing a digital clock using Python. By leveraging Python's
versatile programming capabilities, this project seeks to create a functional and user-friendly digital clock
application. Through detailed exploration of Python libraries and programming techniques, this report will
provide a comprehensive guide to building a reliable digital timekeeping solution.
Benefits:
1. It provides accuracy.
2. Feasible in low light.
A document with definitions of functions and various statements written in Python is called a
Python module. In Python, we can define a module in one of 3 ways:
1
Develop a Digital Clock
o A built-in module, such as the itertools module, is inherently included in the interpreter.
We employ modules to divide complicated programs into smaller, more understandable pieces.
Rather than duplicating their definitions into several applications, we may define our most
frequently used functions in a separate module and then import the complete module.
PACKAGES
A package is considered a collection of tools that allows the programmers to initiate the code. A
Python package acts as a user-variable interface for any source code.
This feature allows a Python package to work at a defined time for any functional script in the
runtime.
A package is a container that contains various functions to perform specific tasks. For example,
the math package includes the sqrt() function to perform the square root of a number.
While working on big projects, we have to deal with a large amount of code, and writing
everything together in the same file will make our code look messy.
Instead, we can separate our code into multiple files by keeping the related code together in
packages.
A Package consists of the __init__.py file for each user-oriented script. However, the same
does not apply to the modules in runtime for any script specified to the users.
A module is a file that contains a Python script in runtime for the code specified to the users.
A package also modifies the user interpreted code in such a manner that it gets easily
operated in the runtime.
2
Develop a Digital Clock
Tkinter
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the
GUI methods, tkinter is the most commonly used method.
It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python tkinter is
the fastest and easiest way to create GUI applications. Creating a GUI using tkinter is an easy
task
.
To create a tkinter Python app:
1. Importing the module – tkinter
2. Create the main window (container)
3. Add any number of widgets to the main window
4. Apply the event Trigger on the widgets.
There are two main methods used which the user needs to remember while creating the Python
application with GUI.
ii. mainloop(): There is a method known by the name mainloop() is used when your
application is ready to run. mainloop() is an infinite loop used to run the application, wait
for an event to occur and process the event as long as the window is not closed.
Time Module
We can always use Python's built-in time module whenever dealing with time-related tasks. There
are several ways to represent time in code, including numbers, strings, and objects.
It also has additional features like the ability to get the current time, wait until the code executes,
pause programme execution, and measure the code's effectiveness.
Python's time module is a very practical tool for manipulating functions and objects that deal with
time. Therefore, we must first import the module in order to begin using the time module in Python.
Python's time module offers functions for dealing with time-related tasks.
The important concept , when dealing with Python time, you’re considering a period of time
identified by a starting point. In computing, you call this starting point the epoch.
3
Develop a Digital Clock
The epoch, then, is the starting point against which you can measure the passage of time.
You may want to convert the Python time, represented as the number of elapsed seconds since the
epoch, to a string. You can do so using ctime()
The string representation of time, also known as a timestamp, returned by ctime() is formatted
with the following structure:
2. Implementation:
Understood the working of tkinter and time modules. We studied about different methods
associated with these modules and built a program of digital clock that takes the system time and
displays it accurately.
4
Develop a Digital Clock
7.0 Outputs of the Micro-Project:
Program Code:
#24-HOURS CLOCK
import time
app_window = Tk()
app_window.title("Digital Clock")
app_window.geometry("420x150")
app_window.resizable(2,2)
background = "yellow"
foreground= "black"
border_width = 25
label.grid(row=0, column=1)
def digital_clock():
time_live = time.strftime("%H:%M:%S")
label.config(text=time_live)
label.after(200, digital_clock)
digital_clock()
app_window.mainloop()
5
Develop a Digital Clock
Output:
1. Understood the use and concept of various built-in modules and packages in python.
2. Able to implement the knowledge of tkinter and time module practically.
1. Used in all kinds of electronic devices such as Radios, Television, Microwaves, Computers and
cell phones.
2. Used probably in many places such as schools, hospitals, offices in order to get accurate time in
hours, minutes and seconds.
10.0 References: