Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make all time greeter using python

import datetime
import time
import pyttsx3
hour = datetime.datetime.now().strftime("%I")
am_or_pm = datetime.datetime.now().strftime("%p")
morning = False
afternoon = False
evening = False
night = False
while True:
    if int(hour) <= 8 and am_or_pm == "AM" and morning == False:
        pyttsx3.speak("Good morning sir")
        morning = True
    elif int(hour) == 12 and am_or_pm == "PM" and afternoon == False:
        pyttsx3.speak("Good afternoon sir")
        afternoon = True
    elif int(hour) >= 4 and am_or_pm == "PM" and evening == False:
        pyttsx3.speak("Good evening sir")
        evening = True
    elif int(hour) == 7 and am_or_pm == "PM" :
        pyttsx3.speak("sir would you like to take a break")
        morning = False
        afternoon = False
        evening = False
        
    time.sleep(10)
        
Comment

PREVIOUS NEXT
Code Example
Python :: exact distance math 
Python :: Change the year in 2nd line to get the answer for the year you want. Ex: year=2010 
Python :: python check string float 
Python :: how to open a website with selenium python 
Python :: send email with python 
Python :: how to check if a proxy is dead in python 
Python :: filter an importrange 
Python :: create directory python if not exist 
Python :: opencv imshow resize 
Python :: how to add scrollbar to listbox in tkinter 
Python :: django datetimefield default 
Python :: python write csv line by line 
Python :: python log transform column 
Python :: how to create notification in python 
Python :: np zeros in more dimensions 
Python :: python how to install numpy on pycharm 
Python :: usong brave browser pyhton 
Python :: how to check if a number is odd python 
Python :: removing a channel from aconda 
Python :: python comprehension with sum 
Python :: crop image python 
Python :: pygame doesnt dedect collision between sprite and image 
Python :: requests post with headers python 
Python :: python no new line 
Python :: binary number in python 32 bit 
Python :: apply strip() a column in pandas 
Python :: foreign key constraint failed django 
Python :: convert hex to decimal python 
Python :: python loop certain number of times 
Python :: next day in python without using datetime 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =