INTRODUCTION – Getting your Python on
You will explore some popular operating systems in this module. Other key objectives include equipping code written in Python in order to engage efficiently with these popular systems; an aspect covered in detail in this module. Furthermore, the module also provides guidance on steps that are involved in setting up an environment to have the newly written codes and testing them through a demonstration to see them in operation. This provides further opportunity to explore setting up your environment, with a demonstration, and otherwise go through-day by -day experience. In all, you should have managed python by this module.
An integration section for this module is one that involves Python modules to perform specific tasks within its scope.
Intended for students to shed light on differences between interpreted and compiled languages.
Gains here would refer to benefits attached to automated intelligence and also opportunity to discuss a few of the common challenges. You’ll be introduced to the concept of Qwiklabs for hands-on, graded assessments.
Learning Objectives
- Understand the different components and core functions of an operating system.
- Learn about the difference between interpreted and compiled programming languages.
- What exactly is an Integrated Development Environment and what does it do about programming?
- Install and get a Python running on a local machine.
- Explain more about automation, its advantages, and the things that can go wrong all in automation.
Practice Quiz: Getting Ready for Python
1. Which of the following is the most modern, up-to-date version of Python?
- Python 3 (CORRECT)
- Python 2
- Python 4
- Anaconda
Great job! Python 3 remains the most current major iteration of Python, and Python 3.8.0, which was officially launched on October 14, 2019.
2. Which of the following operating systems is compatible with Python 3?
- Redhat Linux
- Microsoft Windows
- Apple MacOS
- All of the above (CORRECT)
Nice work! A cross-platform programming language which could run in various operating system is Python.
3. Which of the following operating systems does not run on a Linux kernel?
- Android
- Chrome OS
- Mac OS (CORRECT)
- Ubuntu
Right on! Endeavouring at convenience, ease, and security.
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 (CORRECT)
- python –version (CORRECT)
- python –help
- python –v
Perfect! How the trained machine proceeds is to execute the command python -V or –python version, where “V” has an uppercase “V” and no spaces in between.
Well! Proceeding how the model has learned to execute the command python -V or –python version where “V” has an uppercase “V” and no spaces in between.
5. What is pip an example of?
- A programming language
- An operating system
- A repository of Python modules
- A Python package manager (CORRECT)
Nice work! The simpler truth is the reality about the potential uses of the software, plus the revolutions that make it a new efficient system and platform for Python development.
6. Which of the following is NOT an open-source OS?
- Ubuntu Linux
- FreeBSD
- Android
- Microsoft Windows (CORRECT)
Right on! The Microsoft Company is responsible for churning out the Windows operating system which is a proprietary OS.
7. What is the name of the command line tool commonly used to install, update, and remove external Python modules mentioned in the video?
- pip (CORRECT)
- PyPI
- python3 –version
- conda
Awesome! A package manager is software that enables you to download, install, update, and erase software packages of a particular programming language.
PRACTICE QUIZ: RUNNING PYTHON LOCALLY
1. When your IDE automatically creates an indent for you, this is known as what?
- Interpreted language
- Code reuse
- Code completion (CORRECT)
- Syntax highlighting
Great job, you made it! Basically, the completion feature is IDE in such a manner that it provides users with hints about what follows up in their code and what to finish.
2. 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 function is not indented properly.
- numpy is not imported correctly because as is used.
- The shebang line is not necessary.
- The y variable is not calling the numpy module properly. (CORRECT)
Nice one! While the x variable is using numpy appropriately, it is being used according to the local name – the case with y. Therefore, this inconsistency may result in an error.
3. Which type of programming language is read and converted to machine code before runtime, allowing for more efficient code?
- Object-oriented language
- Compiled language (CORRECT)
- Interpreted language
- Intermediate code
Awesome! Most of the phase taken within a language precedes or during the phases of parsing and is therefore quite separated from possible future improvements which might find ways of shortening the phase.
4. Which of the following is not an IDE or code editor?
- Eclipse
- pip (CORRECT)
- Atom
- PyCharm
Right on! The package manager pip is used in Python to install packages from repositories such as PyPI.
5. What does the PATH variable do?
- Tells the operating system where to find executables (CORRECT)
- 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
Nice work! The PATH variable tells the operating system where to find executables.
6. Which of the following programming languages are interpreted languages?
- Java and C#
- Python and Javascript (CORRECT)
- C++ and Go
- C and Rust
Nailed it! What interpreted languages lack in runtime performance, due to absence of compilation, they make up for by using interpreters to execute the code directly.
7. What is the purpose of using a shebang line in a Python file?
- To tell the operating system where to find programs to execute.
- To tell the operating system to execute a file in the current directory.
- To specify beforehand what command to use when running the script. (CORRECT)
- To make the specified file executable by changing permissions.
Keep it up! At the beginning of a script, the line “#!/usr/bin/env python3” specifies to the operating system what command should be used to execute the script.
8. 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?
- use datetime
- using datetime
- date_time = datetime
- import datetime. (CORRECT)
You got it! To incorporate any module placed in the PATH directory, the keyword is import. Above this, we get to assign a local name to the module by making it import as.
9. Which of the following is NOT an example of code completion?
- After you type the letters “ret”, your IDE finishes your sentence with return.
- After typing the opening parentheses after a function, your IDE inputs the final parentheses.
- After typing “def”, your IDE detects that you are typing a function and highlights it. (CORRECT)
- After typing the first few letters of an existing variable, your IDE suggests that variable, highlighting the suggestion.
Excellent! It would enhance its readability and understanding by making distinctions between coding components, such as keywords and variables.
PRACTICE QUIZ: AUTOMATION
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?
- 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
- 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 (CORRECT)
- Provide a tablet computer to the employee to record uptime and downtime
Nice touch; And now you’ve got an electrical example using Python (plus a little extra hardware) to automate something and save good old human time. The difficulty of the solutions will increase greatly from case to case, depending on when the time-saving effect will occur.
2. 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 organize logs in a way that makes debugging easier. (CORRECT)
- It’s important to remember that 20% of our tasks as system administrators is responsible for 80% of our total workload.
- It’s important to have staff trained on how automation processes work so they can be maintained and fixed when they fail.
Exactly! The forensic value in automation means the idea we draw if debugging is going on; that every move by my automation scripting is properly logged, helping to trace and understand the action performed by the script while it is carried out.
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 their other duties. Assume that one month is four weeks, and it will take him 10 hours to code the automation script. Using the formula [time_to_automate < (time_to_perform * amount_of_times_done)], how long would it take them in minutes before they save time on the process?
- 100 minutes (CORRECT)
- 50 minutes
- 40 minutes
- 1 minute
Awesome! It would take the employee 100 minutes before they save time on the process.
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?
- 24 weeks
- 2 weeks
- 6 weeks
- 240 weeks (CORRECT)
Right on! It’s safe to say that the company won’t find it worth it’s time to automate.
5. Which of the following are valid methods to prevent silent automation errors? (Check all that apply)
- Regular consistency checks (CORRECT)
- Internal issue tracker entries (CORRECT)
- Email notifications about errors (CORRECT)
- Constant human oversight
Nice going! Automated verification checks, such as hash check with backup, are some of the best practices when it comes to early discovery of problems.
Nice work! You can ensure nice records for issues through error report entries within internal issue tracking for automation scripts.
Nice job! One must have email notifications for error or completion of work accomplished needed to ensure that some form of information is passed on to us with respect to the entire process.
6. In terms of automation, which of the following is an example of scalability?
- You fix an error in a script and it’s fixed there, once and forever.
- 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. (CORRECT)
- A company hires more IT staff to keep up with work levels.
- Minimizing workloads to stay within current productivity levels
Nice job! Scalability is the ability of a computer server to be able to handle an increased load by bringing more resources online in order to most efficiently perform additional tasks.
7. Which of the following correctly describes the Pareto Principle?
- If we estimate that it’d take less time to automate the task than to do it manually, chances are it’s a good candidate for automation.
- Four fifths of the sysadmin tasks you perform comprise one fifth of your total workload.
- One fifth of the sysadmin tasks you perform comprise four fifths of your total workload. (CORRECT)
- Is the time and effort it takes to write the script worth the potential automation benefits?
Awesome! The 80-20 Rule states that 20% of the tasks in system administration should contribute 80% of the effort. Such tasks can be identified and automated to boost productivity radically.
8. 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 (CORRECT)
- Automate a process that will take longer to implement than it takes to do manually
- Automate a process you might never use again
- Automate a five-minute process that occurs once every six months
Awesome! Advanced concepts of this enigmatic technology will always ensure the fact that real work is doing the job that an operating system would usually chance to perform so while the current focus is on automated maintenance in logging onto a machine in the virtual environment or letting embedded applications, such a function does not yet assume control.
MODULE 1 GRADED ASSESSMENT
1. Which of the following statements most accurately defines automation? Select all that apply.
- The process of streamlining workflows and making operations more efficient. (CORRECT)
- Tasks that have been done manually previously that can be done at a faster rate.
- The implementation of computer-controlled systems to manage and execute processes. (CORRECT)
- The use of software or technology to perform tasks that would otherwise be done manually. (CORRECT)
Correct
2. Which of the following is an open source operating system?
- Linux OS (CORRECT)
- Apple
- Windows OS
- Mac OS
Correct
3. You run the command python –version and see the output Python 3.9.9. Which version of Python is your computer running?
- Python 2
- Python
- Python 3 (CORRECT)
- Python Unlimited
Correct
4. Which of the following best describes a compiled language?
- A programming language that is converted into machine code before execution. (CORRECT)
- A programming language that is typically slower than interpreted languages.
- A programming language that is executed line by line by an interpreter.
- A programming language that is typically used for scripting and web development.
Correct
5. You are a software developer working on a new project to create a web application. You are using a popular IDE called PyCharm to write your code. PyCharm provides a variety of features to help you develop your code, including a code editor, a debugger, and a terminal. Which of the following statements best describes the purpose of an IDE?
- An IDE is a tool that helps software developers test their code for bugs.
- An IDE is a tool that helps software developers write, debug, and test their code. (CORRECT)
- An IDE is a tool that helps software developers deploy their code to production.
- An IDE is a tool that helps software developers write their code more quickly and efficiently.
Correct
6. You are a site reliability engineer (SRE) responsible for maintaining the production environment for a popular web application. The application is built using a variety of Python frameworks and libraries, and new features are being added regularly. You are finding it increasingly difficult to manage the dependencies for the application. New releases of libraries can introduce breaking changes, and it can be challenging to keep track of which versions of each library are compatible with each other. You have heard about virtual environments, and you are wondering if they might be a solution to your problem. Which of the following statements best describes how virtual environments can help you solve your problem?
- Virtual environments allow you to debug your code more efficiently.
- Virtual environments allow you to install libraries in a way that is isolated from your system Python environment. (CORRECT)
- Virtual environments allow you to test different versions of Python on your system.
- Virtual environments allow you to deploy your code to production more easily.
Correct
7. You work for a growing company that just hired a large number of employees. To efficiently onboard a large number of new employees within a short timeframe. Previously the company had onboarded new hires manually. This is not possible anymore. What is the solution to this problem?
- Develop a software application or utilize existing automation tools to automate the creation of user accounts, mailboxes, and home folders (CORRECT)
- Utilize virtual machines so that several employees can import their information at once.
- Hire another person to help onboard these new employees.
- Create a centralized repository or knowledge base containing all necessary onboarding information, including company policies, procedures, and training materials.
Correct
8. According to the Pareto Principle, what percentage of system administration tasks typically account for 80% of the workload?
- 80%
- 10%
- 20% (CORRECT)
- 50%
Correct
9. A company uses a script to automatically generate reports from their customer relationship management (CRM) system. The script extracts data from the CRM system, formats the data into a report, and saves the report to a file. Which of the following statements best describes the purpose of the script? Select all that apply.
- To save time and effort by automating the process of generating reports. (CORRECT)
- To improve the accuracy and consistency of reports. (CORRECT)
- To make it easier for users to access and analyze data from the CRM system. (CORRECT)
- To increase security of the reports stored in the system.
Correct
10. A banking company is looking to automate one of its internal processes that takes about 50 minutes each week to complete. The automation process will take 12 hours total to complete. How many weeks will it be before the banking company begins to save time on the process?
- 600 days
- 15 weeks
- 50 weeks
- 12 WEEKS (CORRECT)
Correct
11. Which operating system can you use Python on? Select all that apply.
- Linux OS (CORRECT)
- Windows OS (CORRECT)
- Mac OS (CORRECT)
- Dell OS (CORRECT)
Correct
12. You are a software developer working on a new project to create a web application. You want to be able to develop your code in one place. You know you will need a code editor, debugger, and terminal. What should you use to create this application?
- A Linux virtual machine
- An operating system
- An IDE (CORRECT)
- A Text Editor
Correct
13. You are a busy marketing manager at a fast-paced startup company. You are constantly sending out emails to promote your company’s products and services. However, you are finding that this task is taking up a lot of your time. What could you implement to save time on this task?
- Virtual Environments
- Java
- Email templates
- Automation (CORRECT)
Correct
14. Which of the following factors would suggest that a task is a good candidate for automation? Select all that apply.
- The task is repetitive and time consuming.
- The task is error prone and difficult to complete manually. (CORRECT)
- The task is done quickly.
- The task must be performed once a year.
Correct
15. You are writing a python script and need to be able to copy, delete, move, and list files and directories? Which Python module should you use?
- psutil
- matplotlib
- shutil (CORRECT)
- pandas
Correct
16. What are the two main parts of an operating system?
- core and system resources
- kernel and user space (CORRECT)
- system and user space
- hard drive and kernel
Correct
17. You are a software developer working on a new project to create a web application. You are using a popular IDE called PyCharm to write your code. PyCharm provides a variety of features to help you develop your code, including a code editor, a debugger, and a terminal. Which of the following statements best describes the purpose of an IDE?
- An IDE is a tool that helps software developers deploy their code to production.
- An IDE is a tool that helps software developers write, debug, and test their code. (CORRECT)
- An IDE is a tool that helps software developers write their code more quickly and efficiently.
- An IDE is a tool that helps software developers test their code for bugs.
Correct
18. You are an IT automation engineer working on an automation script. You are using a variety of Python libraries in your script. You are also using a variety of different versions of these libraries. You are working on a team with other engineers, and you are finding it difficult to manage the different versions of Python libraries that everyone is using. You are worried that this will lead to conflicts and errors when you try to run your code. You have heard about virtual environments, and you are wondering if they might be a solution to your problem. Which of the following statements best describes how virtual environments can help you solve your problem?
- Virtual environments allow you to test different versions of Python on your system.
- Virtual environments allow you to debug your code more efficiently.
- Virtual environments allow you to install libraries in a way that is isolated from your system Python environment. (CORRECT)
- Virtual environments allow you to deploy your code to production more easily.
Correct
19. A company hires a lot of employees over a short period of time. Previously, the company completed onboarding tasks such as creating a user account, a mailbox, and a home folder, and setting up the appropriate permissions to control access to various systems and resources for each new employee manually. Because of this increase in new hires it would take a lot of time to onboard all of these new employees. What is the solution to this problem?
- Java
- Virtual Environments
- Onboarding templates
- Automation (CORRECT)
Correct
20. You want to create a Python script that automates system monitoring tasks on your computer. What Python module should you use in your script?
- pandas
- psutil (CORRECT)
- numpy
- matplotlib
Correct
21. What are some of the common Linux distributions? Select all that apply.
- Red Hat (CORRECT)
- Kernel
- Debian (CORRECT)
- Ubuntu (CORRECT)
Correct
22. What command should you type into your computer’s terminal to check which Python version is installed?
- python installed — version
- py check — version
- py verify — version
- python –version (CORRECT)
Correct
23. Which of the following statements accurately describes the difference between compiled and interpreted languages?
- Compiled languages are typically faster than interpreted languages, while interpreted languages are more flexible and easier to develop. (CORRECT)
- Interpreted languages are faster than compiled languages and are less prone to errors.
- Interpreted languages are typically used for system programming, while compiled languages are typically used for scripting and web development.
- Interpreted languages are converted into machine code before execution, while compiled languages are executed line by line by an interpreter.
Correct
24. Which formula would you use to determine if a task would save labor time and should be automated?
- time_to_perform < (time_to_automate * amount_of_times_done) amount_of_times_done < (time_to_automate * time_to_perform) time_to_automate > (time_to_perform * amount_of_times_done)
- time_to_automate < (time_to_perform * amount_of_times_done) (CORRECT)
Correct
CONCLUSION – Getting your Python on
In conclusion, the module has given an extensive exploration on operating systems and how to prepare Python codes to cooperate efficiently with a lot of systems. One of the significant aspects was setting up the environment while installing additional Python modules, as needed. It focused on clarifying an understanding of the distinction between interpreted and compiled languages.
Furthermore, the module devoted attention to the gains and losses linked with automation. Also, introducing Quicklabs brought fresh air to the students’ assessment and learning, as it provided a platform for lab-type work with which they could fiddle around. Such knowledge makes you well-suited to making proper navigation through operating systems and the effective deployment of Python in your coding projects.