Answers for "python script to sleep computer"

36

sleep function python

import time

print("Printed immediately.")
time.sleep(2.4)
print("Printed after 2.4 seconds.")
Posted by: Guest on November-23-2019
3

how to make computer go in sleep mode using pythn

import psutil
import time
import pyttsx3
import os
while True:
    time.sleep(5)
    battery = psutil.sensors_battery()
    print("Battery percentage : ", battery.percent)
    print("Power plugged in : ", battery.power_plugged)
    print()
    if battery.percent < 25 and battery.power_plugged == False:
        print("Your battey is low on power")
        pyttsx3.speak("Your battery is low on power")
        if battery.percent <= 20 and battery.power_plugged == False:
            pyttsx3.speak("power in fast")
            time.sleep(5)
            pyttsx3.speak("Turning my prosegers on")
            time.sleep(10)
            if battery.power_plugged == False:  os.system("shutdown /s /t 1")
    elif battery.percent > 95 and battery.power_plugged == True:
        pyttsx3.speak("Your laptop has charged enough")
        print("Your laptop has charged enough")
Posted by: Guest on June-30-2021

Code answers related to "python script to sleep computer"

Python Answers by Framework

Browse Popular Code Answers by Language