In the following programs you will learn that how to open and close computer application. And how to print text file text on Printer.
import subprocess
notepadProcess = subprocess.Popen("Notepad")
while notepadProcess.poll() is None:
print('still running')
reply = input("Kill process ? (type yes) ")
print('>>|'+reply.strip()+'|<<')
if reply.strip()=='yes':
print("closing process")
notepadProcess.terminate()
import os
os.system("TASKKILL /F /IM notepad.exe")
import os
print("Start process to shut down computer")
os.system("Shutdown -s") #Shutdowning Computer.
import os
print("Start process to print text of MyTxtFile text file")
os.startfile("C://MyTxtFile.txt", "print")