Using Python to interact with the Operating System complete course is currently being offered by Google through Coursera platform and is Course 2 of 6 in the Google IT Automation with Python Course.
Check out: How to Apply for Coursera Financial Aid

Course Link: https://www.coursera.org/learn/python-operating-system
Using Python to interact with the Operating System Week 1 Quiz Answers
Practice Quiz Answers: Getting Ready for Python
Question 1)
Which of the following is the most modern, up-to-date version of Python?
- Python 3
- Python 2
- Python 4
- Anaconda
Question 2)
Which of the following operating systems is compatible with Python 3?
- Apple MacOS
- Redhat Linux
- Microsoft Windows
- All of the above
Question 3)
Which of the following operating systems does not run on a Linux kernel?
- Mac OS
- Ubuntu
- Android
- Chrome OS
Question 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 -V
- python –version
- python –help
Question 5)
What is pip an example of?
- A programming language
- An operating system
- A repository of Python modules
- A Python package manager
Practice Quiz Answers: Running Python Locally
Question 1)
When your IDE automatically creates an indent for you, this is known as what?
- Code reuse
- Code completion
- Interpreted language
- Syntax highlighting
Question 2)
Can you identify the error in the following code?
- The shebang line is not necessary.
- numpy is not imported correctly because as is used.
- The function is not indented properly.
- The y variable is not calling the numpy module properly.
Question 3)
Which type of programming language is read and converted to machine code before runtime, allowing for more efficient code?
- Compiled language
- Interpreted language
- Intermediate code
- Object-oriented language
Question 4)
Which of the following is not an IDE or code editor?
- pip
- Atom
- PyCharm
- Eclipse
Question 5)
What does the PATH variable do?
- Returns the current working directory
- Tells the operating system where to find executables
- Holds the command line arguments of your Python program in a list
- Tells the operating system where to cache frequently used files
Practice Quiz Answers: Automation
Question 1)
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?
- Hire an extra employee to track uptime and downtime for each machine
- Provide a tablet computer to the employee to record uptime and downtime
- 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
Question 2)
One important aspect of automation is forensic value. Which of the following statements describes this term correctly?
- 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.
- 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.
Question 3)
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]
Question 4)
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
Question 5)
Which of the following are valid methods to prevent silent automation errors? (Check all that apply)
- Constant human oversight
- Regular consistency checks
- Internal issue tracker entries
- Email notifications about errors
Using Python to interact with the Operating System Week 2 Quiz Answers
Practice Quiz: Managing Files & Directories
Question 1)
The create_python_script function creates a new python script in the current working directory, adds the line of comments to it declared by the ‘comments’ variable, and returns the size of the new file. Fill in the gaps to create a script called "program.py".
def create_python_script(filename):
comments = "# Start of a new Python program"
with open(filename, 'w') as file:
filesize = file.write(comments)
return(filesize)
print(create_python_script("program.py"))
Output:
31
Question 2)
The new_directory function creates a new directory inside the current working directory, then creates a new empty file inside the new directory, and returns the list of files in that directory. Fill in the gaps to create a file "script.py" in the directory “PythonPrograms”.
import os
def new_directory(directory, filename):
# Before creating a new directory, check to see if it already exists
if os.path.isdir(directory) == False:
os.mkdir(directory)
# Create the new file inside of the new directory
os.chdir(directory)
with open (filename, 'w') as file:
file.write("")
# Return the list of files in the new directory
os.chdir('..')
return os.listdir(directory)
print(new_directory("PythonPrograms", "script.py"))
Output:
['script.py']
Question 3)
Which of the following methods from the os module will create a new directory?
- mkdir()
- chdir()
- path.isdir()
- listdir()
Question 4)
The file_date function creates a new file in the current working directory, checks the date that the file was modified, and returns just the date portion of the timestamp in the format of yyyy-mm-dd. Fill in the gaps to create a file called “newfile.txt” and check the date that it was modified.
import os
import datetime
def file_date(filename):
# Create the file in the current directory
with open (filename,'w') as file:
pass
timestamp = os.path.getmtime(filename)
# Convert the timestamp into a readable format, then into a string
timestamp = datetime.datetime.fromtimestamp(timestamp)
# Return just the date portion
# Hint: how many characters are in “yyyy-mm-dd”?
return ("{}".format(timestamp.strftime("%Y-%m-%d")))
print(file_date("newfile.txt"))
# Should be today's date in the format of yyyy-mm-dd
Output:
2020-07-18
Question 5)
The parent_directory function returns the name of the directory that’s located just above the current working directory. Remember that ‘..’ is a relative path alias that means “go up to the parent directory”. Fill in the gaps to complete this function.
import os
def parent_directory():
# Create a relative path to the parent
# of the current working directory
relative_parent = os.path.abspath('..')
# Return the absolute path of the parent directory
return relative_parent
print(parent_directory())
Output:
Answer: /
Practice Quiz Answers: Reading & Writing CSV Files
Questing 1)
We’re working with a list of flowers and some information about each one. The create_file function writes this information to a CSV file. The contents_of_file function reads this file into records and returns the information in a nicely formatted block. Fill in the gaps of the contents_of_file function to turn the data in the CSV file into a dictionary using DictReader.
import os
import csv
# Create a file with data in it
def create_file(filename):
with open(filename, "w") as file:
file.write("name,color,type\n")
file.write("carnation,pink,annual\n")
file.write("daffodil,yellow,perennial\n")
file.write("iris,blue,perennial\n")
file.write("poinsettia,red,perennial\n")
file.write("sunflower,yellow,annual\n")
# Read the file contents and format the information about each row
def contents_of_file(filename):
return_string = ""
# Call the function to create the file
create_file(filename)
# Open the file
with open(filename) as file:
# Read the rows of the file into a dictionary
reader = csv.DictReader(file)
# Process each item of the dictionary
for row in reader:
return_string += "a {} {} is {}\n".format(row["color"], row["name"], row["type"])
return return_string
#Call the function
print(contents_of_file("flowers.csv"))
Note
This question throws:
Output:
- a pink carnation is annual
- a yellow daffodil is perennial
- a blue iris is perennial
- a red poinsettia is perennial
- a yellow sunflower is annual
Question 2)
Using the CSV file of flowers again, fill in the gaps of the contents_of_file function to process the data without turning it into a dictionary. How do you skip over the header record with the field names?
import os
import csv
# Create a file with data in it
def create_file(filename):
with open(filename, "w") as file:
file.write("name,color,type\n")
file.write("carnation,pink,annual\n")
file.write("daffodil,yellow,perennial\n")
file.write("iris,blue,perennial\n")
file.write("poinsettia,red,perennial\n")
file.write("sunflower,yellow,annual\n")
# Read the file contents and format the information about each row
def contents_of_file(filename):
return_string = ""
# Call the function to create the file
create_file(filename)
# Open the file
with open(filename, "r") as file:
# Read the rows of the file
rows = csv.reader(file)
# Process each row
for row in list(rows)[1:]:
name, color, types = row
# Format the return string for data rows only
return_string += "a {} {} is {}\n".format(color, name, types)
return return_string
#Call the function
print(contents_of_file("flowers.csv"))
Output:
- a blue iris is perennial
- a pink carnation is annual
- a yellow daffodil is perennial
- a red poinsettia is perennial
- a yellow sunflower is annual
Question 3)
In order to use the writerows() function of DictWriter() to write a list of dictionaries to each line of a CSV file, what steps should we take? (Check all that apply)
- Import the OS module
- Open the csv file using with open
- Create an instance of the DictWriter() class
- Write the fieldnames parameter into the first row using writeheader()
Question 4)
Which of the following is true about unpacking values into variables when reading rows of a CSV file? (Check all that apply)
- An instance of the reader class must be created first
- The CSV file does not have to be explicitly opened
- We need the same amount of variables as there are columns of data in the CSV
- Rows can be read using both csv.reader and csv.DictReader
Question 5)
If we are analyzing a file’s contents to correctly structure its data, what action are we performing on the file?
- Parsing
- Reading
- Writing
- Appending
Using Python to interact with the Operating System Week 3 Quiz Answers
Practice Quiz: Regular Expressions
Questing 1)
When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
- re.findall(fu$, text)
- re.findall(^un, text)
- re.findall(f.n, text)
- re.findall(f*n, text)
Question 2)
Which of the following is NOT a function of the Python regex module?
- re.findall()
- re.grep()
- re.search()
- re.match()
Question 3)
The circumflex [^] and the dollar sign [$] are anchor characters. What do these anchor characters do in regex?
- Match the start and end of a line
- Match the start and end of a word.
- Exclude everything between two anchor characters
- Represent any number and any letter character, respectively
Question 4)
When using regex, some characters represent particular types of characters. Some examples are the dollar sign, the circumflex, and the dot wildcard. What are these characters collectively known as?
- Literal characters
- Special characters
- Anchor characters
- Wildcard characters
Question 5)
What is grep?
- A command-line regex tool
- A type of special character
- An operating system
- A command for parsing strings in Python
Practice Quiz: Basic Regular Expressions
Question 1)
The check_web_address function checks if the text passed qualifies as a top-level web address, meaning that it contains alphanumeric characters (which includes letters, numbers, and underscores), as well as periods, dashes, and a plus sign, followed by a period and a character-only top-level domain such as “.com”, “.info”, “.edu”, etc. Fill in the regular expression to do that, using escape characters, wildcards, repetition qualifiers, beginning and end-of-line characters, and character classes.
import re
def check_web_address(text):
pattern = r'^[\w\._-]*\.[A-Za-z]*$'
result = re.search(pattern, text)
return result != None
print(check_web_address("gmail.com")) # True
print(check_web_address("www@google")) # False
print(check_web_address("www.Coursera.org")) # True
print(check_web_address("web-address.com/homepage")) # False
print(check_web_address("My_Favorite-Blog.US")) # True
Output:
- True
- False
- True
- False
- True
Question 2)
The check_time function checks for the time format of a 12-hour clock, as follows: the hour is between 1 and 12, with no leading zero, followed by a colon, then minutes between 00 and 59, then an optional space, and then AM or PM, in upper or lower case. Fill in the regular expression to do that. How many of the concepts that you just learned can you use here?
import re
def check_time(text):
pattern = r'^(1[0-2]|1?[1-9]):([0-5][0-9])( ?([AaPp][Mm]))'
result = re.search(pattern, text)
return result != None
print(check_time("12:45pm")) # True
print(check_time("9:59 AM")) # True
print(check_time("6:60am")) # False
print(check_time("five o'clock")) # False
Output:
- True
- True
- False
- False
Question 3)
The contains_acronym function checks the text for the presence of 2 or more characters or digits surrounded by parentheses, with at least the first character in uppercase (if it’s a letter), returning True if the condition is met, or False otherwise. For example, “Instant messaging (IM) is a set of communication technologies used for text-based communication” should return True since (IM) satisfies the match conditions.” Fill in the regular expression in this function:
import re
def contains_acronym(text):
pattern = r'\(+[A-Z0-9][a-zA-Z]*\)'
result = re.search(pattern, text)
return result != None
print(contains_acronym("Instant messaging (IM) is a set of communication technologies used for text-based communication")) # True
print(contains_acronym("American Standard Code for Information Interchange (ASCII) is a character encoding standard for electronic communication")) # True
print(contains_acronym("Please do NOT enter without permission!")) # False
print(contains_acronym("PostScript is a fourth-generation programming language (4GL)")) # True
print(contains_acronym("Have fun using a self-contained underwater breathing apparatus (Scuba)!")) # True
Output:
- True
- True
- False
- True
- True
Question 4)
What does the “r” before the pattern string in re.search(r”Py.*n”, sample.txt) indicate?
- Result
- Raw strings
- Regex
- Repeat
Questing 5)
What does the plus character [+] do in regex?
- Matches plus sign characters
- Matches the end of a string
- Matches one or more occurrences of the character before it
- Matches the character before the [+] only if there is more than one
Question 6)
Fill in the code to check if the text passed includes a possible U.S. zip code, formatted as follows: exactly 5 digits, and sometimes, but not always, followed by a dash with 4 more digits. The zip code needs to be preceded by at least one space, and cannot be at the start of the text.
import re
def check_zip_code (text):
result = re.search(r' \d{5}| \d{5}-\d{4}', text)
return result != None
print(check_zip_code("The zip codes for New York are 10001 thru 11104.")) # True
print(check_zip_code("90210 is a TV show")) # False
print(check_zip_code("Their address is: 123 Main Street, Anytown, AZ 85258-0001.")) # True
print(check_zip_code("The Parliament of Canada is at 111 Wellington St, Ottawa, ON K1A0A9.")) # False
Output:
- True
- False
- True
- False
Practice Quiz Answers: Advanced Regular Expressions
Question 1)
We’re working with a CSV file, which contains employee information. Each record has a name field, followed by a phone number field, and a role field. The phone number field contains U.S. phone numbers, and needs to be modified to the international format, with “+1-” in front of the phone number. Fill in the regular expression, using groups, to use the transform_record function to do that.
import re
def transform_record(record):
new_record = re.sub(r",(\d{3})",r",+1-\1",record)
return new_record
print(transform_record("Sabrina Green,802-867-5309,System Administrator"))
# Sabrina Green,+1-802-867-5309,System Administrator
print(transform_record("Eli Jones,684-3481127,IT specialist"))
# Eli Jones,+1-684-3481127,IT specialist
print(transform_record("Melody Daniels,846-687-7436,Programmer"))
# Melody Daniels,+1-846-687-7436,Programmer
print(transform_record("Charlie Rivera,698-746-3357,Web Developer"))
# Charlie Rivera,+1-698-746-3357,Web Developer
Output:
- Sabrina Green,+1-802-867-5309,System Administrator
- Eli Jones,+1-684-3481127,IT specialist
- Melody Daniels,+1-846-687-7436,Programmer
- Charlie Rivera,+1-698-746-3357,Web Developer
Question 2)
The multi_vowel_words function returns all words with 3 or more consecutive vowels (a, e, i, o, u). Fill in the regular expression to do that.
import re
def multi_vowel_words(text):
pattern = r'\w+[aiueo]{3,}\w+'
result = re.findall(pattern, text)
return result
print(multi_vowel_words("Life is beautiful"))
# ['beautiful']
print(multi_vowel_words("Obviously, the queen is courageous and gracious."))
# ['Obviously', 'queen', 'courageous', 'gracious']
print(multi_vowel_words("The rambunctious children had to sit quietly and await their delicious dinner."))
# ['rambunctious', 'quietly', 'delicious']
print(multi_vowel_words("The order of a data queue is First In First Out (FIFO)"))
# ['queue']
print(multi_vowel_words("Hello world!"))
# []
Output:
- ['beautiful']
- ['Obviously', 'queen', 'courageous', 'gracious']
- ['rambunctious', 'quietly', 'delicious']
- ['queue']
- []
Question 3)
When capturing regex groups, what datatype does the groups method return?
- A list
- A float
- A string
- A tuple
Question 4)
The transform_comments function converts comments in a Python script into those usable by a C compiler. This means looking for text that begins with a hash mark (#) and replacing it with double slashes (//), which is the C single-line comment indicator.
For the purpose of this exercise, we’ll ignore the possibility of a hash mark embedded inside of a Python command, and assume that it’s only used to indicate a comment. We also want to treat repetitive hash marks (###), (####), etc., as a single comment indicator, to be replaced with just (//) and not (#//) or (//#). Fill in the parameters of the substitution method to complete this function:
import re
def transform_comments(line_of_code):
result = re.sub(r'\#{1,}', r'//', line_of_code)
return result
print(transform_comments("#### Start of program"))
# Should be "// Start of program"
print(transform_comments(" number = 0 ### Initialize the variable"))
# Should be " number = 0 // Initialize the variable"
print(transform_comments(" number += 1 # Increment the variable"))
# Should be " number += 1 // Increment the variable"
print(transform_comments(" return(number)"))
# Should be " return(number)"
Output:
// Start of program
number = 0 // Initialize the variable
number += 1 // Increment the variable
return(number)
Question 5)
The convert_phone_number function checks for a U.S. phone number format: XXX-XXX-XXXX (3 digits followed by a dash, 3 more digits followed by a dash, and 4 digits), and converts it to a more formal format that looks like this: (XXX) XXX-XXXX. Fill in the regular expression to complete this function.
import re
def convert_phone_number(phone):
result = re.sub(r"\b(\d{3})-(\d{3})-(\d{4})\b", r"(\1) \2-\3", phone)
return result
print(convert_phone_number("My number is 212-345-9999.")) # My number is (212) 345-9999.
print(convert_phone_number("Please call 888-555-1234")) # Please call (888) 555-1234
print(convert_phone_number("123-123-12345")) # 123-123-12345
print(convert_phone_number("Phone number of Buckingham Palace is +44 303 123 7300")) # Phone number of Buckingham Palace is +44 303 123 7300
Output:
- My number is (212) 345-9999.
- Please call (888) 555-1234
- 123-123-12345
- Phone number of Buckingham Palace is +44 303 123 7300
Using Python to interact with the Operating System Week 4 Quiz Answers
Practice Quiz Answers: Data Streams
Question 1)
Which command will print out the exit value of a script that just ran successfully?
- import sys
- echo $?
- echo $PATH
- wc variables.py
Question 2)
Which command will create a new environment variable?
- export
- input
- wc
- env
Question 3)
Which I/O stream are we using when we use the input function to accept user input in a Python script?
- STDIN
- SYS
- STDOUT
- STDERR
Question 4)
What is the meaning of an exit code of 0?
- The program ended successfully.
- The program ended with a ValueError.
- The program ended with a TypeError.
- The program ended with an unspecified error.
Question 5)
Which statements are true about input and raw_input in Python 2? (select all that apply)
- input gets a string from the user.
- raw_input gets a string from the user.
- input performs basic math operations.
- raw_input performs basic math operations.
Practice Quiz Answers: Python Subprocesses
Question 1)
What type of object does a run function return?
- stdout
- returncode
- capture_output
- CompletedProcess
Question 2)
How can you change the current working directory where a command will be executed?
- Use the shell parameter.
- Use the cwd parameter.
- Use the env parameter.
- Use the capture_output parameter.
Question 3)
When a child process is run using the subprocess module, which of the following are true? (check all that apply)
- The child process is run in a secondary environment.
- The parent process is blocked while the child process finishes.
- Control is returned to the parent process when the child process ends.
- The parent process and child process both run simultaneously.
Question 4)
When using the run command of the subprocess module, what parameter, when set to True, allows us to store the output of a system command?
- timeout
- shell
- cwd
- capture_output
Question 5)
What does the copy method of os.environ do?
- Removes a file from a directory
- Joins two strings
- Runs a second instance of an environment
- Creates a new dictionary of environment variables
Practice Quiz: Processing Log Files
Question 1)
You have created a Python script to read a log of users running CRON jobs. The script needs to accept a command line argument for the path to the log file. Which line of code accomplishes this?
- import sys
- usernames = {}
- syslog=sys.argv[1]
- print(line.strip())
Question 2)
Which of the following is a data structure that can be used to count how many times a specific error appears in a log?
- Get
- Search
- Continue
- Dictionary
Question 3)
Which keyword will return control back to the top of a loop when iterating through logs?
- Get
- With
- Search
- Continue
Question 4)
When searching log files using regex, which regex statement will search for the alphanumeric word “IP” followed by one or more digits wrapped in parentheses using a capturing group?
- r"IP \(\d+\)$"
- r"IP \((\d+)\)$"
- b"IP \((\w+)\)$"
- r"IP \((\D+)\)$"
Question 5)
Which of the following are true about parsing log files? (Select all that apply.)
- You should parse log files line by line.
- We have to open() the log files first.
- Load the entire log files into memory.
- It is efficient to ignore lines that don’t contain the information we need.
Using Python to interact with the Operating System Week 5 Quiz Answers
Practice Quiz Answers: Simple Tests
Question 1)
You can verify that software code behaves correctly using test ___.
- Cases
- Loops
- Functions
- Arguments
Question 2)
What is the most basic way of testing a script?
- Let a bug slip through.
- Write code to do the tests.
- Codifying tests into the software.
- Different parameters with expected results.
Question 3)
When a test is codified into its own software, what kind of test is it?
- Unit test
- Automatic test
- Sanity testing
- Integration test
Question 4)
Using _ simplifies the testing process, allowing us to verify the program’s behavior repeatedly with many possible values.
- interpreter
- integration tests
- test cases
- test-driven development
Question 5)
The more complex our code becomes, the more value the use of _____ provides in managing errors.
- loops
- functions
- parameters
- software testing
Practice Quiz Answers: Other Test Concepts
Question 1)
In what type of test is the code not transparent?
- Smoke test
- White-box test
- Black-box test
- Test-driven development
Question 2)
Verifying an automation script works well with the overall system and external entities describes what type of test?
- Load test
- Smoke test
- Integration test
- Regression test
Question 3)
ensures that any success or failure of a unit test is caused by the behavior of the unit in question, and doesn’t result from some external factor.
- Integration
- Isolation
- Regression testing
- White-box testing
Question 4)
A test that is written after a bug has been identified in order to ensure the bug doesn’t show up again later is called ______.
- Load test
- Smoke test
- Black-box test
- Regression test
Question 5)
What type of software testing is used to verify the software’s ability to behave well under significantly stressed testing conditions?
- Load test
- Smoke test
- Black-box test
- Regression test
Using Python to interact with the Operating System Week 6 Quiz Answers
Practice Quiz: Advanced Bash Concepts
Question 1)
Which command does the while loop initiate a task(s) after?
- do
- n=1
- done
- while
Question 2)
Which line is correctly written to start a FOR loop with a sample.txt file?
- for sample.txt in file; do
- do sample.txt for file
- for sample.txt do in file
- for file in sample.txt; do
Question 3)
Which of the following Bash lines contains the condition of taking an action when n is less than or equal to 9?
- while [ $n -lt 9 ]; do
- while [ $n -ge 9 ]; do
- while [ $n -ot 9 ]; do
- while [ $n -le 9 ]; dowhile [ $n -le 9 ]; do
Question 4)
Which of the following statements are true regarding Bash and Python? [Check all that apply]
- Bash scripts work on all platforms.
- If a script requires testing, Python is preferable.
- Complex scripts are better suited to Python.
- Python can more easily operate on strings, lists, and dictionaries.
Question 5)
The _ command lets us take only bits of each line using a field delimiter.
- mv
- cut
- echo
- sleep
Practice Quiz: Bash Scripting
Question 1)
Which of the following commands will output a list of all files in the current directory?
- **echo ***
- echo a*
- echo *.py
- echo ?.py
Question 2)
Which module can you load in a Python script to take advantage of star [*] like in BASH?
- ps
- Glob
- stdin
- Free
Question 3)
Conditional execution is based on the _ of commands.
- parameters
- exit status
- test results
- environment variables
Question 4)
What command evaluates the conditions received on exit to verify that there is an exit status of 0 when the conditions are true, and 1 when they are false?
- echo
- export
- test
- grep
Question 5)
The opening square bracket ([), when combined with the closing square bracket (]), is an alias for which command?
- if
- glob
- test
- export
Practice Quiz Answers: Interacting with the Command Line
Question 1)
Which of the following commands will redirect errors in a script to a file?
- user@ubuntu:~$ ./calculator.py < error_file.txt
- user@ubuntu:~$ ./calculator.py >> error_file.txt
- user@ubuntu:~$ ./calculator.py 2> error_file.txt
- user@ubuntu:~$ ./calculator.py > error_file.txt
Question 2)
When running a kill command in a terminal, what type of signal is being sent to the process?
- PID
- SIGINT
- SIGTERM
- SIGSTOP
Question 3)
What is required in order to read from standard input using Python?
- cat file.txt
- echo file.txt
- Stdin file object from sys module
- The file descriptor of the STDIN stream
Question 4)
___ are tokens delivered to running processes to indicate the desired action.
- Methods
- Signals
- Functions
- Commands
Question 5)
In Linux, what command is used to display the contents of a directory?
- pwd
- ls
- rmdir
- cp
Post a Comment