CHAPTER2 AUTOMATION::USING PYTHON TO INTERACT WITH OS WEEK1

Ace your homework & exams now with Quizwiz!

Can you identify the error in the following code? #!/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 print(numpyArray())

The y variable is not calling the numpy module properly (While the x variable is calling numpy using its declared local name, y is not using the local name. This will result in an error.)

Proper code reuse is important, so let's see if you were paying attention. Which of the following lines will allow you to use the datetime module in your script?

import datetime. (We use the import command to import any module located in the PATH directory. We can also use import as to assign a localName variable to the imported module.)

What does the PATH variable do?

tells the operating system where to find executables

Which of the following could be a good example of when to use an automation script?

Detect dangerously high CPU usage levels across a network and scale back the CPU clock speeds of those devices, or shut them down to prevent overheating (These days most consumer devices do this on their own, but in the case of custom hardware or other specific use cases such as cluster networks, automation would fit this task nicely and reduce failover.)

Which of the following correctly describes the Pareto Principle?

One fifth of the sysadmin tasks you perform comprise four fifths of your total workload. (The Pareto Principle states that 20% of the system administration tasks you perform are responsible for 80% of your workload. Therefore, identifying and automating those tasks will put your productivity through the roof!)

Which of the following operating systems is compatible with Python 3?

Redhat Linux Microsoft Windows Apple MacOS (Python is a cross-platform language. You can use it on Windows, macOS, Linux, and even on lesser-known Unix variants like FreeBSD.)

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?

240 weeks (It's safe to say that the company won't find it worth it's time to automate.)

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?

Add the analog Internet of Things (IoT) module to each machine, in order to detect their power states and write a script to records uptime and downtime, reporting hourly (This is a practical application of using Python (and some extra hardware, in this case) to automate a task, freeing up a human's time. The solutions can be complex if the return in saved human time warrants it.)

Which of the following is NOT an example of code completion?

After you type the letters "ret", your IDE finishes your sentence with return. (YES) After typing the opening parentheses after a function, your IDE inputs the final parentheses. (YES) After typing "def", your IDE detects that you are typing a function and highlights it. (NO) (Syntax highlighting detects the language we're writing our code in and highlights the pieces of code that make up the syntax of the language.) After typing "def", your IDE detects that you are typing a function and highlights it. (YES) After typing the first few letters of an existing variable, your IDE suggests that variable, highlighting the suggestion. (YES)

In terms of automation, which of the following is an example of scalability?

An IT engineer writes a script to compile a report on each machine's uptime and downtime for the day and email it to relevant parties every evening. (Scalability means that when more work is added to a system, the system can do whatever it needs to complete the work.)

Which type of programming language is read and converted to machine code before runtime, allowing for more efficient code?

Compiled Language (A compiled language is translated into code readable by the target machine during development using a compiler.)

Which of the following is NOT an IDE or code editor?

Eclipse (YES) Atom(YES) PyCharm(YES) pip (NO) -- The package manager pip is used in Python to install packages from repositories such as PyPI.

Which of the following are valid methods to prevent silent automation errors? (Check all that apply)

Email notification about errors (Email notifications for errors or task completions can help keep track of automated processes.) Internal Issue Tracker Entries (Internal issue tracker entries are created as part of reporting on errors in our automation script in this lesson.) regular consistency check (Automated consistency checks, such as hash checks on backups, can help identify problems ahead of time.)

One important aspect of automation is forensic value. Which of the following statements describes this term correctly?

It is important to automated processes to leave extensive logs so when errors occur , they can be properly investigated (Forensic value, in relation to automation, is the value we get while debugging from properly logging every action our automation scripts take.)

Which of the following operating systems does not run on a Linux kernel?

MacOS (Mac OS is a proprietary operating system designed by Apple and uses a proprietary kernel based on BSD.)

Which of the following is the most modern, up-to-date version of Python?

Python 3 is the latest version of Python, with Python 3.8.0 being released on October 14, 2019.

What is the purpose of using a shebang line in a Python file?

To specify beforehand what command to use when running the script (Inserting a shebang line (such as #!/usr/bin/env python3) as the first line tells the operating system what command we want to use to execute the script.)

When your IDE automatically creates an indent for you, this is known as what?

code completion (Code completion is an IDE feature that takes educated guesses about what you might be trying to type next, and offers suggestions to complete it for you.)

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 < (15minutes * 60 times/month)] then automate (With 10 hours to automate, the employee will start saving time before the month is over.)

f 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 (Typing python -V (note the capital V) at the command line will tell you if Python is currently installed and if so, what version.) python --version (Typing python --version (note the double dashes) at the command line will tell you if Python is currently installed and if so, what version.)


Related study sets

Chapter 2 Mastering A&P Homework

View Set

Chapter 15: Fetal Assessment During Labor

View Set

Principles of Microeconomics - Chapters 14-21 (Exam 3)

View Set

Sensation and Perception: Audition and Touch

View Set

Pharm Assignment 2: Lifespan Considerations, Medication Concepts, Medication Reconciliation, Errors and Safety

View Set

Unit 4, topic 4.1 introduction to political geography study guide

View Set

APHuG - Agriculture Progress Check

View Set

Exam 2: Chapter 3: Life Provisions

View Set

Педагогика понятия 5-6 сем

View Set