@@ -17,10 +17,6 @@ Technology always evolves. What are classes and where do they come from?
让我们一起潜水吧!
## Python 课程:
[Python 编程训练营:从零到英雄](https://gum.co/dcsp)
## Python 类
We can create virtual objects in Python. A virtual object can contain variables and methods. A program may have many different types and are created from a class. Example:
You can start a process in Python using the Popen function call. The program below starts the unix program ‘cat’ and the second parameter is the argument. This is equivalent to ‘cat test.py’. You can start any program with any parameter.
Subprocess has a method call() which can be used to start a program. The parameter is a list of which the first argument must be the program name. The full definition is:
In Python, the Timer class is a subclass of the Thread class. This means it behaves similar. We can use the timer class to create timed threads. Timers are started with the .start() method call, just like regular threads. The program below creates a thread that starts after 5 seconds.
The definition of map is map(function,iterable). It applies a function to every item in the iteratable. We can use map() to on a lambda function with a list:
A set in Python is a collection of objects. Sets are available in Python 2.4 and newer versions. They are different from lists or tuples in that they are modeled after sets in mathematics.
@@ -10,11 +10,6 @@ A tree with eight nodes. The root of the tree (5) is on top.
Python 没有对树的内置支持。
## Related Course:
*[Python 编程训练营:从零变成英雄](https://gum.co/dcsp)
## 二叉树
**A binary****tree** is a data structure where every node has at most two children (left and right child). The **root** of a tree is on top. Every node below has a node above known as the parent node.We define a class thee which has a left and right attribute. From this binary tree we define the root (top of the three) and a left and right node.
@@ -18,7 +18,7 @@ This tiny amount of information, the smallest amount of information that you can
To represent higher numbers than 1, the idea was born to use a sequence of bits. A sequence of eight bits could store much larger numbers, this is called a _byte_. A sequence consisting of ones and zeroes is known as _binary_. Our traditional counting system with ten digits is known as decimal.
Given two inputs, the computer can do several logic operations with those bits. Let’s take the AND operator. If input A and input B are positive, the output will be positive. We will demonstrate the AND operator graphically, the two left ones are input A and input B, the right circle is the output:<caption id=”attachment_843” align=”alignnone” width=”640”]![Bitwise AND](img/a783141f02a6302a2f1e80908156dc5d.jpg)
...
...
@@ -126,7 +126,7 @@ print bin(inputA & inputB) # logical AND on inputA and inputB and output in bi
```
## OR 运算子
## OR 运算符
Now that you have learned the AND operator, let’s have a look at the OR operator. Given two inputs, the output will be zero only if A and B are both zero.<caption id=”attachment_847” align=”alignnone” width=”640”]![binary bitwise OR](img/b726bf5bcea4b7fc5dd8a2908ec4d963.jpg)