How To Shutdown PC using Python

ShutDown PC With Python

Hey my geeky friend today I'm going to tell you something special & geeky. Today you are going to learn that how can you shutdown your PC just using few lines of python code, so without wasting time let's get started.

Here's the our simple python code to ShutDown PC immediately.

#importing OS 

import os

#asking from user

shutdown = input("Do You Want to ShutDown You PC ? (YES / NO): ")

#if user input is NO then

if shutdown == 'NO':


#if user input is YES then


os.system("shutdown /s /t 1")

Explanation :

Here in this code we had first import os library and used os.system function with shutdown /s /t 1 code actually its a shell command. . If you hadn't imported os system in your ide import it using command prompt. One more important thing this program would directly shutdown your PC within few seconds so please make sure you have saved and closed your all important programs and applications before executing this code.

Hope you had liked our article please share with your programmer friends and Follow us on social media to get updated with latest updates, tips and tricks for programmers and developers. 


Popular posts from this blog

👨‍💻 | How To Create Typewriter Effect Using Pure CSS

4 Most Easiest Programming Languages For Beginners | With My Experience & Suggestions