IT 117: Intermediate to Scripting
Answers to Class 10 Ungraded Quiz

  1. What is the name of the module that allows you to interact with the operating system?
    os
  2. Write the Python expression you would use to get the pathname of your current directory.
    os.getcwd()
  3. Write the Python expression you would use to get a list of all entries in your current directory.
    os.listdir('.')
  4. Write the Python statement you would use to change your current directory to your parent directory.
    os.chdir('..')
  5. Write the Python expression you would use to get the value of your PATH variable.
    os.environ['PATH']
  6. Write the Python statement you would use to run the executable file work.sh located in your current directory.
    os.system('./work.sh')
  7. What is the name of the module that allows you to interact with the Python interpreter?
    sys
  8. Write the Python expression that gives the value of the pathname used to run the script.
    sys.argv[0]
  9. Write the Python expression that gives the value of the first command line argument.
    sys.argv[1]
  10. Write the Python statement you would use to stop execution of a script.
    sys.exit()