Jarvis
Now we are going to create a function name wish. In this function J.A.R.V.I.S. will give you a good wish while starts up. Our Jarvis will wish you Good morning, Good Afternoon, Good Evening according to the time. Ok Lets Start our Code.
Wish()
def wish():
hour = int(datetime.datetime.now().hour)
tt = time.strftime("%I %M %p")
if 0 <= hour <= 12:
a = "Good Morning, sir", "Hello sir, Good Morning"
speak(random.choice(a) + "It is" + tt)
elif 12 <= hour < 18:
a = "Good Afternoon, sir", "Hello sir, Good afternoon"
speak(random.choice(a) + "It is" + tt)
else:
a = "Good Evening, sir", "Hello sir, Good Evening"
speak(random.choice(a) + "It is" + tt)
b = "How may I help You sir", "Give me a command sir", "Online and ready sir"
speak("I am Jarvis" + random.choice(b))
Place the above code in between the Previous code and call the function in the main block of the code
which means,
if __name__ == "__main__":
wish()
No comments:
Post a Comment