using python to interact with the operating system week 1 answers
Practice Quiz: Getting Ready for Python
1. Which of the following is the most modern, up-to-date version of Python?
- Python 3
- Python 2
- Python 4
- Anaconda
2. Which of the following operating systems is compatible with Python 3?
- Redhat Linux
- Microsoft Windows
- Apple MacOS
- All of the above
3. Which of the following operating systems does not run on a Linux kernel?
- Android
- Chrome OS
- Mac OS
- Ubuntu
4. If we want to check to see what version of Python is installed, what would we type into the command line? Select all that apply.
- python -V
- python –version
- python –help
- python -v
5. What is pip an example of?
- A programming language
- An operating system
- A repository of Python modules
- A Python package manager
6. When your IDE automatically creates an indent for you, this is known as what?
- Interpreted language
- Syntax highlighting
- Code reuse
- Code completion
7. Can you identify the error in the following code?
#!/usr/bin/env python3import numpy as np
def numpyArray(): x = np.array([[1, 2, 3], [4, 5, 6]], np.int32) y = numpy.array([[3, 6, 2], [9, 12, 8]], np.int32) return x*yprint(numpyArray())
#!/usr/bin/env python3
import numpy as np
def numpyArray():
x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
y = numpy.array([[3, 6, 2], [9, 12, 8]], np.int32)
return x*y
- The y variable is not calling the numpy module properly.
- The function is not indented properly.
- The shebang line is not necessary.
- numpy is not imported correctly because as is used.
8. Which type of programming language is read and converted to machine code before runtime, allowing for more efficient code?
- Object-oriented language
- Compiled language
- Interpreted language
- Intermediate code
9. Which of the following is not an IDE or code editor?
- Eclipse
- pip
- Atom
- PyCharm
10. What does the PATH variable do?
- Tells the operating system where to find executables
- Returns the current working directory
- Holds the command line arguments of your Python program in a list
- Tells the operating system where to cache frequently used files
11. At a manufacturing plant, an employee spends several minutes each hour noting uptime and downtime for each of the machines they are running. Which of the following ideas would best automate this process?
- Provide a tablet computer to the employee to record uptime and downtime
- Hire an extra employee to track uptime and downtime for each machine
- Add an analog Internet of Things (IoT) module to each machine, in order to detect their power states, and write a script that records uptime and downtime, reporting hourly
- Add an analog IoT module to each machine, in order to detect their power states, and attach lights that change color according to the power state of the machine
12. One important aspect of automation is forensic value. Which of the following statements describes this term correctly?
- It is important for automated processes to leave extensive logs so when errors occur, they can be properly investigated.
- It’s important to have staff trained on how automation processes work so they can be maintained and fixed when they fail.
- It’s important to organize logs in a way that makes debugging easier.
- It’s important to remember that 20% of our tasks as system administrators is responsible for 80% of our total workload.
13. An employee at a technical support company is required to collate reports into a single file and send that file via email three times a day, five days a week for one month, on top of his other duties. It takes him about 15 minutes each time. He has discovered a way to automate the process, but it will take him at least 10 hours to code the automation script. Which of the following equations will help them decide whether it's worth automating the process?
- if [10 hours to automate > (15 minutes * 60 times per month)] then automate
- if [10 hours to automate < (15 minutes * 60 times per month)] then automate
- if [(10 hours to automate + 15 minutes) > 60 times per month)] then automate
- [(10 hours to automate / 60 times per month) < 15 minutes]
14. A company is looking at automating one of their internal processes and wants to determine if automating a process would save labor time this year. The company uses the formula [time_to_automate < (time_to_perform * amount_of_times_done) to decide whether automation is worthwhile. The process normally takes about 10 minutes every week. The automation process itself will take 40 hours total to complete. Using the formula, how many weeks will it be before the company starts saving time on the process?
- 6 weeks
- 2 weeks
- 24 weeks
- 240 weeks
15. Which of the following are valid methods to prevent silent automation errors? (Check all that apply)
- Email notifications about errors
- Internal issue tracker entries
- Constant human oversight
- Regular consistency checks