IT 117: Intermediate to Scripting
Answers to Class 10 Ungraded Quiz
-
What is the name of the module that allows you to interact with the operating system?
os
-
Write the Python expression you would use to get the pathname of your current directory.
os.getcwd()
-
Write the Python expression you would use to get a list of all entries in your current directory.
os.listdir('.')
-
Write the Python statement you would use to change your current directory to your parent directory.
os.chdir('..')
-
Write the Python expression you would use to get the value of your PATH variable.
os.environ['PATH']
-
Write the Python statement you would use to run the executable file work.sh
located in your current directory.
os.system('./work.sh')
-
What is the name of the module that allows you to interact with the Python interpreter?
sys
-
Write the Python expression that gives the value of the pathname used to run the script.
sys.argv[0]
-
Write the Python expression that gives the value of the first command line argument.
sys.argv[1]
-
Write the Python statement you would use to stop execution of a script.
sys.exit()