Python 3 Script to Shutdown or Switch Off PC Using OS Module Full Project For Beginners

Python 3 Script to Shutdown or Switch Off PC Using OS Module Full Project For Beginners

 

Welcome folks today in this post we will be shutting down pc using os module in python. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to create an app.py file and copy paste the following code

 

app.py

 

import os 
  
shutdown = input("Do you wish to shutdown your computer ? (yes / no): ") 
  
if shutdown == 'no': 
    exit() 
else: 
    os.system("shutdown /s /t 1")

 

 

Now if you execute the above script by typing the below command as shown below

READ  Python 3 Web Scraping Script to Scrape ICC Players Rankings in CSV Files Using BeautifulSoup4 and Pandas Library Full Project For Beginners

 

python app.py

 

Now after executing this command the pc will be automatically shut down

Leave a Reply