Using Python to Interact with the Operating System Week 1 Solution

Welcome to Using Python to Interact with the Operating System! You’re joining thousands of learners currently enrolled in the course. I’m excited to have you on my channel and look forward to your contributions to the learning community. This course is a part of Google IT Automation with Python Professional Certificate. Qwiklabs Assessment: “Working with Python Scripts”

By the end of this course, you’ll be able to manipulate files and processes on your computer’s operating system. You’ll also have learned about regular expressions — a very powerful tool for processing text files — and you’ll get practice using the Linux command line on a virtual machine. And, this might feel like a stretch right now, but you’ll also write a program that processes a bunch of errors in an actual log file and then generates a summary file.

That’s a super useful skill for IT Specialists to know.

~:Skills you will learn:~

  • Setting up your Development Environment
  • Regular Expression (REGEX) 
  • Testing in Python 
  • Automating System Administration Tasks with Python 
  • Bash Scripting

Course Link:-

Qwiklabs Assessment: “Working with Python Scripts”


					#!/usr/bin/env python3
import requests
import socket

def check_localhost():
        localhost = socket.gethostbyname('localhost')
        return localhost==""

def check_connectivity():
        request = requests.get("")
        return request.status_code== int(200)
					#!/usr/bin/env python3
from network import *
import shutil
import psutil
def check_disk_usage(disk):
    """Verifies that there's enough free space on disk"""
    du = shutil.disk_usage(disk)
    free = / * 100
    return free > 20
def check_cpu_usage():
    """Verifies that there's enough unused CPU"""
    usage = psutil.cpu_percent(1)
    return usage <75
# If there's not enough disk, or not enough CPU, print an error
if not check_disk_usage('/') or not check_cpu_usage():
elif check_localhost() and check_connectivity():
    print("Everything ok")
    print("Network checks failed")

One thought on “Using Python to Interact with the Operating System Week 1 Solution

Leave a Reply

Your email address will not be published. Required fields are marked *