Skip to content

PCC52 evelinemarques #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: community
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions 52/evelinemarques/pomodoro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from datetime import datetime, timedelta
import winsound
import time


def beep():
frequency = 2500
duration = 100
for i in range(4):
winsound.Beep(frequency, duration)
time.sleep(0.00001)


def decrement(time_wait: timedelta) -> timedelta:
return time_wait - timedelta(seconds=1)


def status(flg: int) -> None:
if flg:
return "break time", 0

else:
return "pomodoro", 1


def countdown(time_p: timedelta, st)-> None:
while time_p > timedelta(seconds=0):
time_p = decrement(time_p)
print(st, ":", time_p, end="\r", flush=True)
time.sleep(1)


if __name__ == "__main__":
time_wait = float(input("Duration in minutes: "))
print('CRTL+C to stop')
time_p = timedelta(minutes=time_wait)

start = True
flg = 0
try:
while start:
st, flg = status(flg)
countdown(time_p, st)
beep()
except KeyboardInterrupt:
print("\nIt is the end")