Python program to create countdown timer #shorts #coding #programming

preview_player
Показать описание


If you found this video useful please give it a thumbs up and subscribe to my channel! and If you have any questions regarding this video, please ask them in the comment section. thanks for watching! :)

Follow Us:

#shorts #coding #programming

DISCLOSURE: This video and description might contain affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support! [Intro Song Credit]
Valence - Infinite [NCS Release]
Рекомендации по теме
Комментарии
Автор

import time

def countdown(s):
[(print(i), time.sleep(1)) if i > 1 else print(i) for i in range(s, 0, -1)]

countdown(5)

diogenescinico
Автор

There's a problem with this. If the minutes is bigger than 99 then the string will be longer than if the minutes was below 100, and also because of this implementation, the last character won't be cleared.

Example output:
"100:02"
"100:01"
"100:00"
"99:590"

The right output would've been "99:59"
A fix for this is to add a space after the timer like this: "99:59 " (see the space), and because the timer's length can only go down by 1 digit, the digit that's not updated anymore will be cleared with the space.

_-
Автор

Omg how i didn't know end='\r'

dp.
Автор

Good code. could’ve been done faster, efficiently but the code works so good work

josephcahoon
Автор

Simply u can use for loop with 1s timer...?
X -=1 itteration..

Just 3 lines

whydoyouwannaknowmyname
Автор

import time
def timer(secs): # secs lol
for i in range(0, secs):
time.sleep(1)
secs -= 1
print(secs, end="\r")

timer(5)

serverok
Автор

I like to use timers in another thread but multitasking sucks in python.

marcelocosta
Автор

I would've used delta time for a more accurate timer

russianyoutube
Автор

It is Easy
I can create progress bar i TKinter

animemchik
Автор

batch:
:init
set a=5
:run
if %a% EQU 0 echo.timeup &exit
timeout -t 1
set a=a-1
echo.%a%
EASY!!

dmsassassin
Автор

Hook it up to some hardware or something and make a function when the timer hits 0 and Activate something

rafin.
Автор

If you want something luxury in your life then start c++ and go for CP and gain top 3 rank. This is the shortest steps to enhance your life!
Thank you for reading 💐

sirbap
Автор

Please add if __name__ == ‘__main__’: to your scripts to run files that aren’t being used as modules. Also make use of f strings instead of .format()

anricoj
Автор

ok. your code works, you pass this round. in next round you will revert a binary tree in 5s, the countdown you write in this round.

quym
Автор

Which visual studio theme do you use?🥺

iboy
Автор

hi how to do this but not time i want my text like this coming

Coio
Автор

Why tons of codes for just a 5 seconds? Can they be condensed?😄

JAM-mllr
Автор

Bhai aap edit kaise krte ho aise video

ChampGamers