From 0e21fb2071e2472074a240d0fffeb88e20d5ae0e Mon Sep 17 00:00:00 2001 From: sun-fibo-intern Date: Sat, 1 Nov 2025 13:22:58 +0530 Subject: [PATCH 1/2] Added real-time date display feature to Digital Clock --- Digital_Clock/digital_clock.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Digital_Clock/digital_clock.py b/Digital_Clock/digital_clock.py index 5e11037..9d6fc29 100644 --- a/Digital_Clock/digital_clock.py +++ b/Digital_Clock/digital_clock.py @@ -11,6 +11,7 @@ def __init__(self, font=None): self.set_font(font) self.add_header() self.add_clock() + self.add_date() # ✅ Added new method to show date self.update_time_on_clock() def create_window(self): @@ -39,6 +40,19 @@ def add_clock(self): 'times', 90, 'bold'), bg='blue', fg='white') self.clock.grid(row=2, column=2, padx=620, pady=250) + def add_date(self): + """Add a date label below the clock.""" + self.date_label = Label(self.window, font=('times', 40, 'bold'), bg='black', fg='white') + self.date_label.grid(row=3, column=2) + self.update_date_on_clock() + + def update_date_on_clock(self): + """Update the date displayed below the clock.""" + currentDate = time.strftime("%d-%b-%Y") + self.date_label.config(text=currentDate) + # Update every midnight (24*60*60*1000 ms) + self.date_label.after(86400000, self.update_date_on_clock) + def update_time_on_clock(self): """Update the time displayed on the clock every second.""" currentTime = time.strftime("%H:%M:%S") @@ -53,4 +67,3 @@ def start(self): if __name__ == "__main__": clock = DigitalClock() clock.start() - From 42ef4f7247eb572ecbef280710b498f16f25169c Mon Sep 17 00:00:00 2001 From: sun-fibo-intern Date: Sat, 1 Nov 2025 13:38:08 +0530 Subject: [PATCH 2/2] Enhanced Animal Guess Game with random questions and replay feature --- Animal-Guess/animalguess.py | 66 +++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/Animal-Guess/animalguess.py b/Animal-Guess/animalguess.py index 6dc3fe4..311d1de 100644 --- a/Animal-Guess/animalguess.py +++ b/Animal-Guess/animalguess.py @@ -1,25 +1,49 @@ +import random + def check_guess(guess, answer): - global score - still_guessing = True + """Check user's guess and return True if correct.""" attempt = 0 - while still_guessing and attempt < 3: + while attempt < 3: if guess.lower() == answer.lower(): - print("Correct Answer") - score = score + 1 - still_guessing = False + print("✅ Correct Answer!\n") + return True else: - if attempt < 2: - guess = input("Sorry Wrong Answer, try again") - attempt = attempt + 1 - if attempt == 3: - print("The Correct answer is ",answer ) - -score = 0 -print("Guess the Animal") -guess1 = input("Which bear lives at the North Pole? ") -check_guess(guess1, "polar bear") -guess2 = input("Which is the fastest land animal? ") -check_guess(guess2, "Cheetah") -guess3 = input("Which is the larget animal? ") -check_guess(guess3, "Blue Whale") -print("Your Score is "+ str(score)) + attempt += 1 + if attempt < 3: + guess = input("❌ Wrong! Try again: ") + print(f"The correct answer is: {answer}\n") + return False + + +def main(): + print("🐾 Welcome to the Animal Guessing Game! 🐾") + print("You have 3 attempts for each question.\n") + + questions = { + "Which bear lives at the North Pole?": "polar bear", + "Which is the fastest land animal?": "cheetah", + "Which is the largest animal?": "blue whale", + "Which animal is known as the king of the jungle?": "lion", + "Which animal can sleep standing up?": "horse" + } + + score = 0 + # Randomize question order + for question, answer in random.sample(list(questions.items()), 3): + guess = input(question + " ") + if check_guess(guess, answer): + score += 1 + + print(f"🎯 Your final score is: {score}/{len(questions)}") + + # Option to play again + replay = input("\nDo you want to play again? (yes/no): ") + if replay.lower().startswith('y'): + print("\nRestarting game...\n") + main() + else: + print("Thanks for playing! 🦋") + + +if __name__ == "__main__": + main()