Alternative: import time def alarm(secs): for x in range(secs,-1,-1): minutes, seconds = divmod(x,60) print(f" {minutes:02d}:{seconds:02d}",end="") time.sleep(1) print("Time Up!") alarm(5)
@life4s936 Жыл бұрын
nice bro
@papa_AI7 ай бұрын
👍
@janayascott7078 Жыл бұрын
I'm very new to python and just came from the password generator mini project video and was searching for more. Please do more and put them in a playlist. I was told the best way to learn python is to do mini projects and build your skill from there. These are so simple and you explain it so well as we follow along. Thank you so much for doing these! Please keep it up :D
@yagnikbose8973 Жыл бұрын
Same here. I've only done python basics in data structures and several different kinds of programs but not really in terms of utilising software such as alarm clock etc. This is how I'm gaining experience with it.
@shyne4283 Жыл бұрын
it took me 3 hours to figure out. Thank you so much. I am just a beginner.This veido helped me alot.I need that kind of easy projects to upgrade my python level
@soe3717 Жыл бұрын
It didn't work for me, though I did as 10:24 CLEAR_AND_RETURN the code remained exactly equal. keep as a colum of numbers the run keeps like: Alarm Will be sound in: 00:04 Alarm Will be sound in: 00:03 Alarm Will be sound in: 00:02 Alarm Will be sound in: 00:01 Alarm Will be sound in: 00:00 can you help me pls? The code is exactly the same.
@kreollosos3203 Жыл бұрын
I got the same issue
@goldenfox1471 Жыл бұрын
i am also facing the same problem
@dhrubajyotibhattacharjee6609 Жыл бұрын
Although I am not well-informed about the issue, I think the special escape sequence "\033[H" is a terminal control code. As such, you would need to run the program on a terminal only to get the desired output. (Feel free to correct me if I am wrong!)
@batuhanbayr7613 Жыл бұрын
yes me to because we are windows users ı try to fix it but nothing helped @@kreollosos3203
@diegosantosmoto Жыл бұрын
I like so much this kind of project. It's nice to practice and see how it works
@sauraabh Жыл бұрын
Bring more of these small projects please
@peterfargo6044 Жыл бұрын
if anyone has an error with getting "playsound" to install, namely: "note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output." Try opening cmd and running python. pip install --upgrade wheel Then try to run: pip install playsound it fixed my issue.
@tomundsohi5855 Жыл бұрын
Thanks
@esvanadium76324 ай бұрын
can you write the full process? it will be helpful for me
@peterfargo60444 ай бұрын
@@esvanadium7632 It's in my comment above. Just click the Show more. Just be sure to open command prompt (click search type "cmd" +enter, then enter Python by typing "py" then Enter. Then follow the above comment I posted.
@RedRum13472 ай бұрын
Thanks 👍
@usamashami11 Жыл бұрын
I'm enjoying these mini projects
@williamdelatorre9991 Жыл бұрын
For some reason my CLEAR_AND_RETURN = "\033[H" does not work, I am using windows 10 and python V3.11.
@papa_AI7 ай бұрын
it is not compulsory that you use the exact same syntax as other, why not just make another without using this.
@KnowAiShorts2nd6 ай бұрын
for those getting error at CLEAR_AND_RETURN part, replace your print statement with this- print(f" {minutes_left:02d}:{seconds_left:02d}", end='', flush=True) hope this helps........
@WPhoenix-d2o3 ай бұрын
Thx mate
@jamiebritt38182 ай бұрын
thankyou so much
@NiceChange Жыл бұрын
Well that was fun Tim!!! Loved it!!!
@kipngetichabsalom9100 Жыл бұрын
educative content tim,
@philippedid10 ай бұрын
Very nice tip as usual thank you TIM
@SkyFly19853 Жыл бұрын
That can be very useful for video game development...
@Andrew-Tsegaye Жыл бұрын
yep! Definitely
@SkyFly19853 Жыл бұрын
@@Andrew-Tsegaye Indeed!
@pi._. Жыл бұрын
Won’t the alarm sound too late since it takes time for it to execute the lines of code between time.sleep(1)?
@zanus5591 Жыл бұрын
Yes, even time.sleep() takes more than a second to execute. So the alarm will take visibly longer to take off in 1000+ seconds
@mddawid0323 Жыл бұрын
Can you do a video about strucurization of bigger python projects? Where to put the classes, how to enclose helper functions into packages, how to properly name your files?
@fichtensaft5149 Жыл бұрын
Yeh, would be great
@TechWithTim Жыл бұрын
I actually have videos on this already. Look for my "System Design" 2 part series
@fichtensaft5149 Жыл бұрын
@@TechWithTim great, thank you! Gonna watch it
@אילאיברשלום-ק4ז Жыл бұрын
I would like to see you do videos for intermediate or cool medium projects
@baloney_sandwich Жыл бұрын
good stuff Tim
@NiceChange Жыл бұрын
is there a front end for this?
@JashSingh-bv5ge Жыл бұрын
Im facing a problem the code is exact same, but im getting in this kind of output in Terminal --> 00:03 00:02 00:01 00:00 can you Help me out ?
@dyashwanth9822 Жыл бұрын
its working fine for me on Terminal , try on terminal not on output
@Techtalkswithrahul Жыл бұрын
Great video.. please make some videos on API development using python as those are the buzz words nowdays
@xujason4607 Жыл бұрын
Amazing video ,tks Tim !
@KomischeZitrone Жыл бұрын
Thats a realy good Tutorial thx
@Snakyboopface-Tori9 ай бұрын
I cant get the alarm to play it keeps giving me an error also I couldnt hear the alarm in the video
@FallenAngelMMA Жыл бұрын
Thank you so much!
@pablozuta2402 Жыл бұрын
guys if you are getting an error try using a .wav file for the sound
@ssigitas69 Жыл бұрын
I like this small projects. You can see how in practise use function, loops, etc 🤗 But what I still can not understand, in what sequence code must be written? It's looks for me, input should be above def alarm() function. I still can not understand what should be where??? 🤔
@Gigusx Жыл бұрын
Any specific code you have problem with? Generally, you write code in the order that it will be executed, which is from top to bottom. If you have e.g. variables that depend on other variables then you'll have to put them in order that makes sense, as in you can't define variables that other things depend on at the end of the file. All synchronous code (which everyone starts with when they learn to program) follows this flow. /edit as for the input being below def alarm(), it's because "def alarm()" is the function *definition*. When you define a function you only create it but don't run it immediately. The function is run at the line "alarm(total_seconds)" and you ask the user for input before that happens.
@ssigitas69 Жыл бұрын
@@Gigusx thank you so much 😊 I need to see many more projects to understand this. Because when I am learning about loops with users inputs (Sololearn, W3School) they teaches me first going input after while, for loops and conditionals if input blablabla, print this, else, print this
@saranshbalian40148 ай бұрын
Bro , ANSI characters are not working in pycharm help me😢
@niktheos424 ай бұрын
You just need to run it from the terminal
@RandyIsDandy Жыл бұрын
Hey would you mind telling me how you get your text colors that exact way? I really like it
@josh5001 Жыл бұрын
He uses the in-built Monokai color theme
@RandyIsDandy Жыл бұрын
@@josh5001 Thank you man much apprecaited!
@raim_akhmetov8 ай бұрын
Hello, can you help me add an alarm (to the hourly alarm)? In my first year I was given a coursework and I am an aspiring programmer🙏
@dWn2T Жыл бұрын
This looks very smart: "2 from playsound import playsound" I will write for myself...
@0zahim Жыл бұрын
ok
@prashantraj5972 Жыл бұрын
Its for beginners or intermediate?
@Lambyyy Жыл бұрын
Definitely beginner.
@Daviesdev Жыл бұрын
@@Lambyyy exactly
@adityadua3009 Жыл бұрын
I was testing the code and arrived at a breaking point for it. Let's say you input 100 in minutes and 2 in seconds. Instead of showing 99:59 after 3 seconds, it shows 99:590, and so on. Is it possible to fix it, and if there is, could you please explain how?
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@maccleary9576 Жыл бұрын
Hi I am having trouble with getting the print statement to occur in the same line. I coded up the program exactly as you did and instead it still prints on a new line. Could I please have some help?
@youssefsn Жыл бұрын
Great mini project, but why not use divmod() function for time and the os module for clearing?
@Rachinter Жыл бұрын
Very true bro
@doomsdaymaximus10 ай бұрын
is it just me or did anyone else couldn't manage to intall the playsound module either? Mine simply wouldn't get installed.
@WeToddEd-r3g Жыл бұрын
Hi! Mt ansi code for the clear and return doesn't work, and I definitely have "\033[H" for the value. Is there another one that I can use if this one isn't working?
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@Mahesh-ri4xt Жыл бұрын
Same issue
@ryanroberts3003 Жыл бұрын
same issue as well.
@aronds24 Жыл бұрын
Any alternative to clear_and_return?
@abdurrahmanbasil8473 Жыл бұрын
import time def clear_console(): # Print a sufficient number of empty lines to "clear" the console print(" " * 50) def alarm(seconds): time_elapsed = 0 clear_console() while time_elapsed < seconds: time.sleep(1) time_elapsed += 1 time_left = seconds - time_elapsed minutes_left = time_left // 60 seconds_left = time_left % 60 clear_console() print(f"{minutes_left:02d}:{seconds_left:02d}") alarm(10)
@moe9062 Жыл бұрын
We didn't hear any alarm though
@TechWithTim Жыл бұрын
Ya I realized I didn’t have it enabled in my recording, it did work tho
Could you make some tutorials like these for Go? There aren't a lot of good tutorials around :)
@tronicit Жыл бұрын
I had a terrible time getting playsound to work on Python 3.11 (since updated to 3.12). What worked was installing playsound & PyObjC via pycharm. I couldn't install playsound via the terminal in OS X at all no matter what syntax I used. Hope this helps someone. EDIT/Update: Also CLEAR_AND_RETURN didn't work as per other user posts below. EDIT2/Update: the script works in the terminal but not directly in an IDE as the clear command CLEAR_AND_RETURN = "\033[H" only works in a shell.
@AliRaza-pr5tk Жыл бұрын
I have a confusion in minutes left and seconds left ,that what are they doing ?
@pranavireddy8221 Жыл бұрын
plz do more projects
@ssigitas69 Жыл бұрын
I don't know why, but escape sequences don't work for me 😥 anyway printing in new line...
@stevemorse5052 Жыл бұрын
I am having the same problem. @ssigitas69, what OS are you using. I am using Window10, with PyCharm Tim, HELP! It has been 30+ years since I have had to use ANSI escape sequence's.
@stevemorse5052 Жыл бұрын
Just tried the program outside of PyCharm and I am getting the escape sequence's less the \033 printed out
@ssigitas69 Жыл бұрын
@@stevemorse5052 I'm using Windows 11 and Pycharm. First escape sequence doesn't clean terminal, second doesn't work as well
@stevemorse5052 Жыл бұрын
@@ssigitas69 Hi did you read my second response above? The only thing I can think of is that PyCharm runs its own terminal.
@ssigitas69 Жыл бұрын
@@stevemorse5052 yes mate, I read it. But maybe lack of my English, I didn't proper understand what you mean. But yes, maybe problem with Pycharm... I gonna try VScode later. Thank so much
@burstfireno1617 Жыл бұрын
Pyto app for Ipad cant find this module 😫
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@rashichauhan4501 Жыл бұрын
the alarm doesn't work even tho I installed playsound but still its showing error
@Dabber7 Жыл бұрын
please make more mini projects on python
@fargoretro Жыл бұрын
Did not hear the sound.
@batuhanbayr7613 Жыл бұрын
how ı will do this as a windows user?
@gjedda63 Жыл бұрын
How do you know what to import?
@tranminhlong5192 Жыл бұрын
For an expert like him, he probably knows due to his experience in this field. For beginners, u have to do research to gain exp
@truepvp5463 Жыл бұрын
an import is an already premade working snippet of code that u can put into ur code so u can use it aswell instead of having to make it on ur own from scratch, if u ever need something like camera tracking, voice or whatever just look it up and u will find a library that u can download thru pip/pip3, in the video he used the library playsound (which would take a long time to make on ur own) and directly used it in his code
@Ghfddhtvvfdd2421 Жыл бұрын
Can you sell this type of app?
@goldenfox1471 Жыл бұрын
The CLEAR_AND_RETURN is not working. Can anyone help me plz?
@abdurrahmanbasil8473 Жыл бұрын
import time def clear_console(): # Print a sufficient number of empty lines to "clear" the console print(" " * 50) def alarm(seconds): time_elapsed = 0 clear_console() while time_elapsed < seconds: time.sleep(1) time_elapsed += 1 time_left = seconds - time_elapsed minutes_left = time_left // 60 seconds_left = time_left % 60 clear_console() print(f"{minutes_left:02d}:{seconds_left:02d}") alarm(10)
@Mr_Moe_Lesterr Жыл бұрын
Alarm didnt sound for me. I belive you need to provide the full path for playsound otherwise it wont work. I've had that problem a lot.
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@cgmania230 Жыл бұрын
please make more mini projects bro
@learnomics Жыл бұрын
We did not heard the sound
@combogaming8302 Жыл бұрын
how to get this code
@spacechaser2843 Жыл бұрын
Possible in idle
@praveenpcpc Жыл бұрын
Pls make a video Python new version for beginner
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@pottoker612 Жыл бұрын
would have made more sense to add a gui with tkinter and have user input...
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…😊
@ziademad3287 Жыл бұрын
CLEAR_AND_RETURN not working
@winningtech5 Жыл бұрын
I thought we'll be using python scheduler
@scleroman4931 Жыл бұрын
🔥🔥
@OmegaAftermath5 ай бұрын
debugged with llama3-70b, issue with playsound fix was pip install for pygame for mp3 import time import pygame Clear = "\033[2J" Clear_and_return = "\033[H" def alarm(seconds): time_elapsed = 0 print(Clear) while time_elapsed < seconds: time.sleep(1) time_elapsed += 1 time_left = seconds - time_elapsed minutes_left = time_left // 60 seconds_left = time_left % 60 print(f"{Clear_and_return}{minutes_left:02d}:{seconds_left:02d} Alarm will sound in ") # Play the alarm sound pygame.mixer.init() pygame.mixer.music.load("soundcheck.mp3") pygame.mixer.music.play() while pygame.mixer.music.get_busy(): time.sleep(0.1) minutes = int(input("How many minutes to wait: ")) seconds = int(input("How many seconds to wait: ")) total_seconds = minutes * 60 + seconds alarm(total_seconds)
@manan2007 Жыл бұрын
I followed the video and now I can't stop the alarm D:
@Rachinter Жыл бұрын
Divmod and os modules are much easier.
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️…
@HogRiderPodcast25 күн бұрын
125 / 2 does not equal 60
@pottoker612 Жыл бұрын
chat gpt can generate an alarm clock script in about 30 secs...
@timchat9_my_teleqram_id Жыл бұрын
Teleqram me 👆⬆️….
@atrophysicist Жыл бұрын
There was no actual alarm sound
@GTV_367 Жыл бұрын
🙌
@prudhvichinnam1488 Жыл бұрын
No it's not working
@prashantdas3618 Жыл бұрын
tell me your email id I'll send you a simpler version of this programme
@rohitjain6429 Жыл бұрын
If you're talking ANSI characters to delete lines , yes they don't work everywhere, vs code works but run it windows terminal you'll get error
@mayankvaswani100 Жыл бұрын
Bro forgot 60*2 = 120
@gaurangkhera Жыл бұрын
Nah, floor division would return 2, so it was correct.
@truepvp5463 Жыл бұрын
// is how many times 60 could be contained in 120 not the devision FeelsDankMan
@ohhhbirdy5975 Жыл бұрын
yeah we didnt hear it LOL
@BravoSixGoingDark. Жыл бұрын
Is there any python code that simulates beard growth?
@abdenourhajy2006 Жыл бұрын
Man you are Unlucky
@combogaming8302 Жыл бұрын
what is in alarm.mp3 file,tim is not explaining things clearly for the beginners
@shomugger8 ай бұрын
still struggle setting up "playsound". BTW can you make tutorial about python environment. Versions and how to store versions correct way, togeather with scripts or make it global? It's very confusing for newcomers Upd: problem with alarm.mp3 was in that track I downloaded from site provided) I changed track with mine and everything is working) Also I downgrade playsound to version 1.2.2
@JNET_Reloaded Жыл бұрын
nope hered nothing!
@prashantdas3618 Жыл бұрын
for a shorter version, tell me your email id
@ssigitas69 Жыл бұрын
I don't know why, but escape sequences don't work for me 😥 anyway printing in new line...