Day 63 of my Python Journey 👨🏽💻 🥸: Good day guys !! This post should have came in much earlier to be honest 😅. After my python learning session for today, I had to lock in on a particular lab report which I'm submitting tomorrow and I just concluded it after long hours of writing 😤... So today’s learning session was both fun 😊 and insightful as i practiced my knowledge of python dates by building a real life digital clock 🌟 Unlike the past few projects I practiced with that just fetches and displays the current time on my IDE, This project fetches and displays the current system time in real-time. The program runs continuously using an infinite loop and updates the clock every second, just like a real digital clock ✨ Here’s a simple walkthrough of how the program works 👇🏽 ~ datetime.now() function is used to get the current date and time from the system. ~ strftime (string format) was used to format the time so it displays neatly in hours, minutes, and seconds.("%H:%M:%S") ~ The while True loop was implemented and it is main cause of the clock running indefinitely. ~ Finally time.sleep(1) pauses the program for one second, ensuring the clock updates accurately every second. After writing this, I noticed the clock keeps moving to a new line as it counts then i google searched and found out that #\r is used to move the cursor back to the beginning of the line and end="" to prevent printing on a new line, which creates a smooth live-updating clock effect in the terminal. It's incredible to see how just few lines of python code can create a digital clock that runs indefinitely like a real one 👌🏽⚡ Check to see the results below 👇🏽 #Python #LearningProgress #100DaysOfCode #BeginnerProjects #Datetime #ProgrammingJourney #BuildingInPublic #consistency

To view or add a comment, sign in

Explore content categories