Menu Driven Python program for opening the required software Application

11 Aug, 2021
In this article, we will create a menu-driven Python program which will execute the required user tool when user will give the input as a text.
We can interact to OS through GUI (graphical user interface) and CLI (command line interface). We can also give the instructions to OS through programming language. In this program, you can instruct to OS using Python. This program gives the idea of how can we make a rule-based ChatBot.
In this program, we will use os.system() method of OS module. This method executes the command (a string) in a subshell.
Syntax: os.system(command)
Return : On Unix, the return value is the exit status of the process and on Windows, the return value is the value returned by the system shell after running command. 
Let’s see the implementation: 
Python3
# import os libraryimport os # infinite while loopwhile True:    print("Hello! user choose your tool")    print("Choose your tool :-\n")    print("-> mousepad")    print("-> chrome")    print("-> vlc")    print("-> virtualbox")    print("-> camera")    print("-> telegram")    print("-> firefox")    print("-> codeblocks")    print("-> screenshot")    print("-> task-manager")    print("-> libreoffice impress / presentation")    print("-> libreoffice writer / text editor / notepad")    print("-> libreoffice clac / spreadsheets")    print("-> libreoffice")    print("-> jupyter notebook\n")    print("chat with system:-",end=' ')         # take input from user    p = input()           # check conditions    if (("do not" in p) or ("dont" in p) or ("don't" in p)):        print("OK user\n")             elif (("open" in p) or ("start" in p) or ("run" in p) or ("execute" in p) or ("launch" in p) or ("activate" in p)):                 if (("mousepad" in p) or ("editor" in p)):                       # run mention application            os.system("mousepad")                     elif (("vlc" in p) or ("media player" in p)):            os.system("vlc")                     elif (("virtualbox" in p) or ("virtual machine" in p) or ("virtual tool" in p)):            os.system("virtualbox")                     elif (("camera" in p) or ("cheese" in p)):            os.system("cheese")                     elif ("telegram" in p):            os.system("telegram-desktop")                     elif ("codeblocks" in p):            os.system("codeblocks")                     elif ("taskmanager" in p):            os.system("xfce4-taskmanager")                     elif ("screenshot" in p):            os.system("xfce4-screenshooter")                     elif (("jupyter" in p) or ("notebook" in p)):            os.system("jupyter notebook")                     elif (("libreoffice impress" in p) or ("presentation tool" in p)):            os.system("libreoffice --impress")                     elif (("libreoffice writer" in p) or ("text editor" in p)):            os.system("libreoffice --writer")         elif ("notepad" in p):            os.system("notepad")                     elif (("libreoffice calc" in p) or ("spreadsheet" in p)):            os.system("libreoffice --calc")                     elif ("libreoffice" in p):            os.system("libreoffice")                     elif ("chrome" in p):            os.system("google-chrome-stable")                     elif (("firefox" in p) or ("mozilla" in p)):            os.system("firefox")                     else :            print("don't support")         # terminating infinite while loop    elif (("quit" in p) or ("exit" in p) or ("stop" in p) or ("close" in p) or ("deactivate" in p) or ("terminate" in p)):        print("Thnank You!")        break             else :        print("don't support")
Output:
arorakashish0911
sweetyty
kapoorsagar226
Python os-module-programs
python-os-module
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.