Skip to content

Commit 0341ac2

Browse files
committed
Python Simple Pomodoro Timer
1 parent d49deeb commit 0341ac2

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

Pomodoro Timer/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Pomodoro Timer
2+
3+
A simple, customizable command line pomodoro timer built in Python.
4+
5+
## Features
6+
7+
- Customizable work, short and long breaks intervals: Define your own durations for each cycle.
8+
- Cycles: Run Multiple cycles of work and break intervals
9+
- Console output: Show work and break intervals in the console.
10+
11+
## How it works
12+
13+
The Pomodoro Timer follow these steps:
14+
1. Set your work and break intervals.
15+
2. Take a short break every work interval.
16+
3. After a set number of cycles, take a long break.
17+
18+
## Usage
19+
20+
1. Clone this repository to your machine.
21+
2. Run the Python script from the command line.
22+
'''python pomodoro_timer.py'''
23+
24+
## Author
25+
26+
[MeuHubPython](https://github.com/MeuHubPython)
27+

Pomodoro Timer/main.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import time
2+
3+
4+
def countdown(minutes, label):
5+
total_seconds = minutes * 60
6+
while total_seconds:
7+
minutes, seconds = divmod(total_seconds, 60)
8+
timer = f"{minutes:02d}:{seconds:02d}"
9+
print(f"{label} Timer: {timer}", end="\r")
10+
time.sleep(1)
11+
total_seconds -= 1
12+
print(f"\n{label} finished!")
13+
14+
15+
def pomodoro_timer(work_min, short_break_min, long_break_min, cycles):
16+
for i in range(cycles):
17+
print(f"\nCycle {i+1} of {cycles}")
18+
countdown(work_min, "Work")
19+
if i < cycles - 1:
20+
countdown(short_break_min, "Short Break")
21+
else:
22+
countdown(long_break_min, "Long Break")
23+
24+
25+
if __name__ == "__main__":
26+
work_minutes = int(input("Enter work interval in minutes: "))
27+
short_break_minutes = int(input("Enter short break interval in minutes: "))
28+
long_break_minutes = int(input("Enter long break interval in minutes: "))
29+
cycles = int(input("Enter the number of cycles: "))
30+
31+
pomodoro_timer(work_minutes, short_break_minutes, long_break_minutes, cycles)

Pomodoro Timer/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python 3.10.12

0 commit comments

Comments
 (0)