Python Script to Logout 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 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.system() function with the code "shutdown -l" . The shutdown -l command is the windows shell command for logging off. Let's start with how to log out the system with Python. 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 log out your computer. Below is the Python implementation - Python3 1== import os logout = input("Do you wish to log out your computer ? (yes / no): ") if logout == 'no': exit() else: os.system("shutdown -l") Output: Here is the Python Program which will ask the user to log out the computer providing the option of Yes or No. Also, when you type yes & then press the ENTER key, the system will be log out instantly. Comment More infoAdvertise with us Next Article How to clear screen in python? S SohomPramanick Follow Improve Article Tags : Python Python Programs Python-Quizzes python-utility Practice Tags : python Similar Reads 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 Python Script to Shutdown 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 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: 1 min read How to clear screen in python? When working in the Python interactive shell or terminal (not a console), the screen can quickly become cluttered with output. To keep things organized, you might want to clear the screen. In an interactive shell/terminal, we can simply usectrl+lBut, if we want to clear the screen while running a py 4 min read How to Keep a Python Script Output Window Open? We have the task of how to keep a Python script output window open in Python. This article will show some generally used methods of how to keep a Python script output window open in Python. Keeping a Python script output window open after execution is a common challenge, especially when running scri 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