Update
This commit is contained in:
parent
275c83d379
commit
793eff5870
19 changed files with 2117 additions and 1835 deletions
39
python.md
39
python.md
|
@ -26,4 +26,41 @@ What follows is a summary of the python language:
|
|||
- It has a **gigantic standard library** which handles things such as [Unicode](unicode.md), [GUI](gui.md), [databases](database.md), [regular expressions](regex.md), [email](email.md), [html](html.md), [compression](compression.md), communication with operating system, [networking](network.md), [multithreading](multithreading.md) and much, much more. This means it's almost impossible to implement Python in all its entirety without 100 programmers working full time for at least 10 years.
|
||||
- There are numerous other **smaller fails**, e.g. inconsistent/weird naming of built-in commands, absence of switch statement (well, in new versions there is one already, but only added later and looks kinda shitty) etc.
|
||||
|
||||
TODO: code, compare to C
|
||||
## Example
|
||||
|
||||
Here is the **[divisor tree](divisor_tree.md)** program implemented in Python3, it showcases most of the basic language features:
|
||||
|
||||
```
|
||||
# recursive function, prints the divisor tree of a number
|
||||
def printDivisorTree(x):
|
||||
a = -1
|
||||
b = -1
|
||||
|
||||
for i in range(2,int(x / 2) + 1): # find closest divisors
|
||||
if x % i == 0:
|
||||
a = i
|
||||
b = int(x / i)
|
||||
|
||||
if a >= b:
|
||||
break
|
||||
|
||||
print("(",end="")
|
||||
|
||||
if a > 1:
|
||||
printDivisorTree(a)
|
||||
print(" " + str(x) + " ",end="")
|
||||
printDivisorTree(b)
|
||||
else:
|
||||
print(x,end="")
|
||||
|
||||
print(")",end="")
|
||||
|
||||
while True: # main loop, read numbers
|
||||
try:
|
||||
x = int(input("enter a number: "))
|
||||
except ValueError:
|
||||
break
|
||||
|
||||
printDivisorTree(x)
|
||||
print("")
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue