Module 7 challenge: Log Analysis Using Regular Expressions :Using Python to Interact with the Operating System (Google IT Automation with Python Professional Certificate) Answers 2025
1. Primary purpose of using regular expressions in log analysis
❌ To encrypt log data
❌ To compress log files
❌ To format log messages
✔️ To extract specific patterns and information from unstructured log data
2. What grep "ERROR Tried to add information to closed ticket" syslog.log returns
❌ All the closed tickets in syslog
✔️ All the ERROR logs in which the system tried to add information to closed ticket
❌ All the ERROR logs in syslog
❌ A duplicate file of syslog
3. python3 opens a Python shell, also known as
✔️ Python interactive shell
❌ Python script
❌ Python editor
❌ python3 interpreter
4. Sorting dictionary by values with sorted(fruit.items(), key=operator.itemgetter(1))
❌ sorted fruit = {“oranges”: 3, “apples”: 5, “bananas”: 7, “pears”: 2}
❌ [(‘bananas’, 7), (‘apples’, 5), (‘oranges’, 3), (‘pears’, 2)]
❌ [(‘apples’, 5), (‘bananas’, 7), (‘oranges’, 3), (‘pears’, 2)]
✔️ [(‘pears’, 2), (‘oranges’, 3), (‘apples’, 5), (‘bananas’, 7)]
5. Primary advantage of using regular expressions in automation scripts for logs
❌ Automate installation of software
✔️ Flexible pattern matching for extracting specific data from log entries
❌ Simplify creating log files
❌ Enhance visual presentation of log data
6. Why are regular expressions useful?
❌ Perform mathematical operations
✔️ Search and manipulate text based on patterns
❌ Create graphical user interfaces
❌ Connect to databases
7. grep "ERROR" syslog.log returns
❌ All ERROR logs in syslog.log
✔️ The ERROR messages in syslog.log
❌ All logs in syslog.log
❌ All ERROR logs with no corresponding message
8. Python module similar to grep
❌ logsearch
✔️ re (Regular Expression)
❌ grep
❌ logfilter
9. What’s missing from “I want to create a script to sort files”
❌ The problem statement is complete
❌ Does not specify programming language
✔️ Does not specify what files to sort
❌ Does not specify what the script is supposed to do
10. nano user_emails.csv when file doesn’t exist
❌ An error message
❌ A new csv file named nano user_emails.csv
✔️ A new csv file named user_emails.csv
❌ A new csv file populated with user emails
📌 Summary Table
| Q# | Correct Answer(s) |
|---|---|
| 1 | Extract patterns from unstructured log data ✔️ |
| 2 | All ERROR logs with that message ✔️ |
| 3 | Python interactive shell ✔️ |
| 4 | [(‘pears’, 2), (‘oranges’, 3), (‘apples’, 5), (‘bananas’, 7)] ✔️ |
| 5 | Flexible pattern matching ✔️ |
| 6 | Search/manipulate text based on patterns ✔️ |
| 7 | The ERROR messages in syslog.log ✔️ |
| 8 | re module ✔️ |
| 9 | Does not specify what files to sort ✔️ |
| 10 | A new csv file named user_emails.csv ✔️ |