Python Script to Shutdown Computer Last Updated : 14 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report As we know, Python is a popular scripting language because of its versatile features. In this article, we will write a Python script to shutdown a computer. To shut down the computer/PC/laptop by using a Python script, you have to use the os.system() function with the code "shutdown /s /t 1" . Note: For this to work, you have to import os library in the ide. If you don't have it, then 'pip install os' through the Command Prompt. Causion: Please ensure that you save and close all the program before running this code on the IDLE, as the below program will immediately shut down your computer. Below is the Python implementation - Python3 1== import os shutdown = input("Do you wish to shutdown your computer ? (yes / no): ") if shutdown == 'no': exit() else: os.system("shutdown /s /t 1") Output: Here is the Python Program which will ask the user to shut down the computer providing the option of Yes or No. Also, when you type yes & then press the ENTER key, the system will be shut down instantly. Comment More infoAdvertise with us Next Article Making an Alias to Shutdown Ubuntu S SohomPramanick Follow Improve Article Tags : Python Python Programs Python-Quizzes python-utility Practice Tags : python Similar Reads Python Script to Logout Computer As we know, Python is a popular scripting language because of its versatile features. In this article, we will write a Python script to logout a computer. Letâs start with how to logout the system with Python. To logout your computer/PC/laptop only by using a Python script, you have to use the os.sy 2 min read Python Script to Restart Computer As we know, Python is a popular scripting language because of its versatile features. In this article, we will write a Python script to restart a computer. Let's start with how to restart the system with Python. Note: For this to work, you have to import os library in the ide. If you don't have it, 1 min read Making an Alias to Shutdown Ubuntu Ubuntu is a widely used operating system because of its versatile features and security. Most of the professional programmers like to work on it but we don't like to waste our time when it comes to performing basic functions of the computer through GUI. In this article, we will write an alias to Shu 2 min read How to Close MP3 Files Using Python? Manipulating audio files, such as MP3s, is a common task in Python programming, especially in applications involving audio processing, music players, or audio analysis. This article will explore concepts related to this topic and guide how to effectively close MP3 files in Python. Closing MP3 files 2 min read Python Systemexit Exception with Example Using exceptions in Python programming is essential for managing mistakes and unforeseen circumstances. SystemExit is one example of such an exception. This article will explain what the SystemExit exception is, look at some of the situations that might cause it, and provide helpful ways to deal wit 3 min read Running Python program in the background Let us see how to run a Python program or project in the background i.e. the program will start running from the moment device is on and stop at shut down or when you close it. Just run one time to assure the program is error-bug free One way is to use pythonw, pythonw is the concatenation of python 3 min read Like