DEV Community

Oyoh kennedy
Oyoh kennedy

Posted on

Optimizing your productivity: A guide to strategic break during long hour of work.

Can you think of a friend who works for long hours on a computer, programming, writing, and researching for hours? By the way that friend could be you. This seems to be a problem considering the amount of time we spend keeps going up, which in turn affects productivity and creativity.

Here is an article written with Python code that schedules breaks during the day, reminding you to listen to your favourite song on the web or just take a walk from your computer.

Step 1

Start by installing Python on your computer if you don't have it.
https://www.python.org/downloads/release/python-3120/

Step 2

Open a Python application and launch IDE: This is like a note pad or a place where we write codes.

Step 3

Image description

To embed a YouTube video on your webpage, utilize the webbrowser.open function with the video link as the input.

Step 4

Image description

To introduce a time delay in the code, employ the time.sleep function. For instance, to pause for 2 hours before the YouTube video pops up, use time.sleep(2 * 60 * 60) where the value is in seconds.

Step 5

Image description

Implementing a repeated time loop with a total of 3 breaks, initialize variables total_break as 3 and break_count as 0. Utilize a while loop, and incorporate the time.ctime function to track the program's runtime.
Here is the output

Image description

Top comments (3)

Collapse
 
wisdomajola profile image
Oladipupo Wisdom

Impressive ✅✅

Collapse
 
oyohkennedy25 profile image
Oyoh kennedy

Thanks

Collapse
 
glntn101 profile image
Luke

Thanks!