In addition to the kernel (see day7), there are two more components usually associated to the operating system.
The shell. The shell is a process or group of processes that start when the operating system boots and provides the ability to launch other programs. The shell is what draws the taskbar, start menu, dock, android home screen, terminal, etc. It launches and kills other processes based on user interaction. The shell is implemented as a normal process running on top of the kernel: it competes with other processes for the CPU, makes syscalls into the kernel when it wants things done (like draw the taskbar), and in almost all respects acts just like any other process, albeit one tasked with controlling the screen and launching other programs.
Utilities. An operating system usually comes with a large number of utilities (for example, the task manager). These utilities are normal programs and some of them might even be written in python. They are scheduled by the kernel and make syscalls to get things done. Some examples are the file manager and settings/control panel.
Programming languages are made up of three components:
Python defines the syntax and semantics here. As an example, consider the if statement.
The syntax of a programming language is described using Backus-Naur Form. This gives slightly more detail than we discussed in class so I won't rewrite it all.
For example, the python reference uses (a variant) of BNF to describe the syntax of statements, for example the if statement. The BNF syntax is then followed by a description of the semantics. Section 1.2 describes the python variant of BNF.
On day6, you wrote code and used Wallis' and Leibniz's approximations of pi. Convert both of these implementations to functions and put them into the same file. Each function should take one paramter for the number of terms to compute, and return the approximation of pi. That is, create a python file like
def wallis(terms):
# Code for wallis here, where terms is an integer for the number of terms to compute
# return the pi approximation
def leibnitz(terms):
# Code for leibnitz here, where terms is an integer for the number of terms to compute
# return the pi approximation
Add some test code to make sure your code works, for example
print(wallis(1000))