Skip to content

Commit be0a638

Browse files
author
fanslin
committed
添加本地库
1 parent 6e40c18 commit be0a638

10 files changed

Lines changed: 253 additions & 0 deletions

File tree

.gitignore

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
.hypothesis/
51+
.pytest_cache/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
db.sqlite3-journal
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
target/
75+
76+
# Jupyter Notebook
77+
.ipynb_checkpoints
78+
79+
# IPython
80+
profile_default/
81+
ipython_config.py
82+
83+
# pyenv
84+
.python-version
85+
86+
# pipenv
87+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
89+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
90+
# install all needed dependencies.
91+
#Pipfile.lock
92+
93+
# celery beat schedule file
94+
celerybeat-schedule
95+
96+
# SageMath parsed files
97+
*.sage.py
98+
99+
# Environments
100+
.env
101+
.venv
102+
env/
103+
venv/
104+
ENV/
105+
env.bak/
106+
venv.bak/
107+
108+
# Spyder project settings
109+
.spyderproject
110+
.spyproject
111+
112+
# Rope project settings
113+
.ropeproject
114+
115+
# mkdocs documentation
116+
/site
117+
118+
# mypy
119+
.mypy_cache/
120+
.dmypy.json
121+
dmypy.json
122+
123+
# Pyre type checker
124+
.pyre/

BMI.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
height = 1.82
4+
weight = 74.5
5+
bmi = weight/(height*2)
6+
print('BMI = %.2f' %bmi)
7+
if bmi < 18.5:
8+
print('低于18.5:','过轻')
9+
elif bmi >= 18.5 and bmi < 25:
10+
print('18.5-25:','正常')
11+
elif bmi >= 25 and bmi < 28:
12+
print('25-28:','过重')
13+
elif bmi >= 28 and bmi < 32:
14+
print('28-32:','肥胖')
15+
else:
16+
print('高于32:','严重肥胖')

abstest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
# from abstest import my_abs来导入my_abs()函数
4+
def my_abs(x):
5+
if not isinstance(x, (int, float)):
6+
raise TypeError('bad operand type')
7+
if x >= 0:
8+
return x
9+
else:
10+
return -x

dict.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
d = {'A': 95, 'B':75, 'C':85}
4+
s = d['A']
5+
print (s)
6+
d['D'] = 65
7+
print(d.get('B'))
8+
address = d.get("address", "address is Not Exit")
9+
print(address)
10+
11+
s = set([1,2, 3, 4, 2, 4, 1])
12+
print(s)

do_slice.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
5+
6+
print('L[0:3] =', L[0:3])
7+
print('L[:3] =', L[:3])
8+
print('L[1:3] =', L[1:3])
9+
print('L[-2:] =', L[-2:])
10+
11+
R = list(range(100))
12+
print('R[:10] =', R[:10])
13+
print('R[-10:] =', R[-10:])
14+
print('R[10:20] =', R[10:20])
15+
print('R[:10:2] =', R[:10:2])
16+
print('R[::5] =', R[::5])

for.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
names = ['a','b','c']
4+
for name in names:
5+
print(name)
6+
7+
sum = 0
8+
for x in [1,2,3,4,5]:
9+
sum = sum + x
10+
print(sum)
11+
12+
sum = 0
13+
for x in range(101):
14+
sum = sum + x
15+
print(sum)
16+
17+
L = ['Bart', 'Lisa', 'Adam']
18+
for x in L:
19+
print('Hello, %s!!!' %x)
20+
21+
22+
23+
d = {'a':'1', 'b':'2', 'c':'3'}
24+
for key in d:
25+
print(key)
26+
for value in d.values():
27+
print(value)
28+
29+
for k,v in d.items():
30+
print(k ,'=',v)
31+
32+
print([k + '=' + v for k,v in d.items()])
33+
34+
L = ['Hello', 'World', 18, 'Apple', None]
35+
print([s.lower() for s in L if isinstance(s, str)])
36+
37+
#print("")
38+
#for ch in 'ABC':
39+
# print(ch)
40+

if.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
a = int(input('请输入整数:'))
4+
if a >= 0:
5+
print(a)
6+
else:
7+
print(-a)

plus.py

100644100755
File mode changed.

power.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
# from abstest import my_abs来导入my_abs()函数
4+
# x 的 n 次方
5+
6+
def power(x,n = 2):
7+
s = 1
8+
while n > 0:
9+
n = n - 1
10+
s = s * x
11+
return s

while.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
n = 1
4+
while n <= 100:
5+
if n > 10:
6+
break
7+
# print(n)
8+
n = n + 1
9+
print('END')
10+
11+
12+
m = 0
13+
while m < 10:
14+
m = m + 1
15+
if m % 2 == 0:
16+
continue
17+
print(m)

0 commit comments

Comments
 (0)