Answers for "how to use python to sleep if the user is not using the system"

7

how to use python to sleep if the user is not using the system

import time
print("This is how to pause a program")
time.sleep(5)
print("Did you saw that i slept for 5 seconds")
Posted by: Guest on July-27-2021
2

how to use python to sleep if the user is not using the system

import time
import requests
from pprint import pprint

try:
    
    Api_key = "Your api key"
    city_or_country = str(input('Write a "city" or "Country" name for which you want the weather:- '))
    print("Fetching Data of",city_or_country)
    time.sleep(4)
    URL = "https://api.openweathermap.org./data/2.5/weather?appid=" + Api_key + "&q="+ city_or_country
    weather_data = requests.get(URL).json()
    pprint(weather_data)
except ValueError:
    print("incorrect input or API KEY")
Posted by: Guest on June-25-2021
6

how to use python to sleep if the user is not using the system

import screen_brightness_control as screen
sent_the_brightness = screen.set_brightness(10)
get = screen.get_brightness()
print(get)
Posted by: Guest on August-12-2021
3

how to use python to sleep if the user is not using the system

import mouse
import time
import os
import pyttsx3
while True:
    before_sleep = mouse.get_position()
    time.sleep(600)
    after_sleep = mouse.get_position()
    if before_sleep == after_sleep:
        pyttsx3.speak("Going to shut down")
        os.system("shutdown /s /t 1")
Posted by: Guest on August-25-2021
2

how to use python to sleep if the user is not using the system

import os
os.system("start chrome")
os.system("py")
Posted by: Guest on May-10-2021
4

how to use python to sleep if the user is not using the system

import time
import pyttsx3

def countdown(t):
    while t:
        mins, seconds = divmod(t, 60)
        timer = "{:02d}:{:02d}".format(mins,seconds)
        print(timer, end="\r")
        time.sleep(1)
        t -= 1
        
    pyttsx3.speak("Beep Beep Beep Beep Beep Beep")
    pyttsx3.speak("Timer has completed")
    print("Timer has done")
timer = int(input("Enter the time in seconds:- "))

print(countdown(timer))
Posted by: Guest on June-25-2021

Code answers related to "how to use python to sleep if the user is not using the system"

Python Answers by Framework

Browse Popular Code Answers by Language