Skip to content

Commit 6411875

Browse files
committed
更正了部分文档和代码
1 parent 28067bf commit 6411875

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1484
-1709
lines changed

Day01-15/Day01/code/hello.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""
2-
32
第一个Python程序 - hello, world!
43
向伟大的Dennis M. Ritchie先生致敬
54
@@ -9,7 +8,6 @@
98
109
请将该文件命名为hello.py并在终端中通过下面的命令运行它
1110
python hello.py
12-
1311
"""
1412

1513
print('hello, world!')

Day01-15/Day02/code/centigrade.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""
2-
32
将华氏温度转换为摄氏温度
43
F = 1.8C + 32
54
65
Version: 0.1
76
Author: 骆昊
87
Date: 2018-02-27
9-
108
"""
119

1210
f = float(input('请输入华氏温度: '))

Day01-15/Day02/code/circle.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
输入半径计算圆的周长和面积
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
import math

Day01-15/Day02/code/leap.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
输入年份 如果是闰年输出True 否则输出False
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
year = int(input('请输入年份: '))

Day01-15/Day02/code/operator.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
运算符的使用
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = 5

Day01-15/Day02/code/string.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
字符串常用操作
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
str1 = 'hello, world!'

Day01-15/Day02/code/variable1.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
使用变量保存数据并进行操作
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = 321

Day01-15/Day02/code/variable2.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
将input函数输入的数据保存在变量中并进行操作
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = int(input('a = '))

Day01-15/Day02/code/variable3.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
格式化输出
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = int(input('a = '))

Day01-15/Day02/code/variable4.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
检查变量的类型
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = 100

Day01-15/Day02/code/variable5.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
类型转换
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-27
8-
97
"""
108

119
a = 100

Day01-15/Day03/.py

Whitespace-only changes.

Day01-15/Day03/code/convert.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
"""
2-
32
英制单位英寸和公制单位厘米互换
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-28
8-
97
"""
108

119
value = float(input('请输入长度: '))
1210
unit = input('请输入单位: ')
1311
if unit == 'in' or unit == '英寸':
14-
print('%f英寸 = %f厘米' % (value, value * 2.54))
12+
print('%f英寸 = %f厘米' % (value, value * 2.54))
1513
elif unit == 'cm' or unit == '厘米':
16-
print('%f厘米 = %f英寸' % (value, value / 2.54))
14+
print('%f厘米 = %f英寸' % (value, value / 2.54))
1715
else:
18-
print('请输入有效的单位')
16+
print('请输入有效的单位')

Day01-15/Day03/code/grade.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
"""
2-
32
百分制成绩转等级制成绩
4-
90分以上 --> A
5-
80分~89分 --> B
6-
70分~79分 --> C
7-
60分~69分 --> D
8-
60分以下 --> E
3+
90分以上 --> A
4+
80分~89分 --> B
5+
70分~79分 --> C
6+
60分~69分 --> D
7+
60分以下 --> E
98
109
Version: 0.1
1110
Author: 骆昊
1211
Date: 2018-02-28
13-
1412
"""
1513

1614
score = float(input('请输入成绩: '))
1715
if score >= 90:
18-
grade = 'A'
16+
grade = 'A'
1917
elif score >= 80:
20-
grade = 'B'
18+
grade = 'B'
2119
elif score >= 70:
22-
grade = 'C'
20+
grade = 'C'
2321
elif score >= 60:
24-
grade = 'D'
22+
grade = 'D'
2523
else:
26-
grade = 'E'
24+
grade = 'E'
2725
print('对应的等级是:', grade)

Day01-15/Day03/code/piecewise.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
"""
2-
32
分段函数求值
4-
3x - 5 (x > 1)
5-
f(x) = x + 2 (-1 <= x <= 1)
6-
5x + 3 (x < -1)
3+
3x - 5 (x > 1)
4+
f(x) = x + 2 (-1 <= x <= 1)
5+
5x + 3 (x < -1)
76
87
Version: 0.1
98
Author: 骆昊
109
Date: 2018-02-28
11-
1210
"""
1311

1412
x = float(input('x = '))
1513
if x > 1:
16-
y = 3 * x - 5
14+
y = 3 * x - 5
1715
elif x >= -1:
18-
y = x + 2
16+
y = x + 2
1917
else:
20-
y = 5 * x + 3
18+
y = 5 * x + 3
2119
print('f(%.2f) = %.2f' % (x, y))

Day01-15/Day03/code/rolldice.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
"""
2-
32
掷骰子决定做什么事情
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-28
8-
97
"""
108

119
from random import randint
1210

1311
face = randint(1, 6)
1412
if face == 1:
15-
result = '唱首歌'
13+
result = '唱首歌'
1614
elif face == 2:
17-
result = '跳个舞'
15+
result = '跳个舞'
1816
elif face == 3:
19-
result = '学狗叫'
17+
result = '学狗叫'
2018
elif face == 4:
21-
result = '做俯卧撑'
19+
result = '做俯卧撑'
2220
elif face == 5:
23-
result = '念绕口令'
21+
result = '念绕口令'
2422
else:
25-
result = '讲冷笑话'
23+
result = '讲冷笑话'
2624
print(result)

Day01-15/Day03/code/tax.py

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
"""
2-
32
输入月收入和五险一金计算个人所得税
3+
说明:写这段代码时新的个人所得税计算方式还没有颁布
44
55
Version: 0.1
66
Author: 骆昊
77
Date: 2018-02-28
8-
98
"""
109

1110
salary = float(input('本月收入: '))
1211
insurance = float(input('五险一金: '))
1312
diff = salary - insurance - 3500
1413
if diff <= 0:
15-
rate = 0
16-
deduction = 0
14+
rate = 0
15+
deduction = 0
1716
elif diff < 1500:
18-
rate = 0.03
19-
deduction = 0
17+
rate = 0.03
18+
deduction = 0
2019
elif diff < 4500:
21-
rate = 0.1
22-
deduction = 105
20+
rate = 0.1
21+
deduction = 105
2322
elif diff < 9000:
24-
rate = 0.2
25-
deduction = 555
23+
rate = 0.2
24+
deduction = 555
2625
elif diff < 35000:
27-
rate = 0.25
28-
deduction = 1005
26+
rate = 0.25
27+
deduction = 1005
2928
elif diff < 55000:
30-
rate = 0.3
31-
deduction = 2755
29+
rate = 0.3
30+
deduction = 2755
3231
elif diff < 80000:
33-
rate = 0.35
34-
deduction = 5505
32+
rate = 0.35
33+
deduction = 5505
3534
else:
36-
rate = 0.45
37-
deduction = 13505
35+
rate = 0.45
36+
deduction = 13505
3837
tax = abs(diff * rate - deduction)
3938
print('个人所得税: ¥%.2f元' % tax)
4039
print('实际到手收入: ¥%.2f元' % (diff + 3500 - tax))

Day01-15/Day03/code/triangle.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""
2-
32
判断输入的边长能否构成三角形
43
如果能则计算出三角形的周长和面积
54
65
Version: 0.1
76
Author: 骆昊
87
Date: 2018-02-28
9-
108
"""
119

1210
import math
@@ -15,9 +13,9 @@
1513
b = float(input('b = '))
1614
c = float(input('c = '))
1715
if a + b > c and a + c > b and b + c > a:
18-
print('周长: %f' % (a + b + c))
19-
p = (a + b + c) / 2
20-
area = math.sqrt(p * (p - a) * (p - b) * (p - c))
21-
print('面积: %f' % (area))
16+
print('周长: %f' % (a + b + c))
17+
p = (a + b + c) / 2
18+
area = math.sqrt(p * (p - a) * (p - b) * (p - c))
19+
print('面积: %f' % (area))
2220
else:
23-
print('不能构成三角形')
21+
print('不能构成三角形')

Day01-15/Day03/code/verify.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""
2-
32
用户身份验证
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-02-28
8-
97
"""
108

119
# import getpass
@@ -17,6 +15,6 @@
1715
# 输入口令的时候终端中没有回显
1816
# password = getpass.getpass('请输入口令: ')
1917
if username == 'admin' and password == '123456':
20-
print('身份验证成功!')
18+
print('身份验证成功!')
2119
else:
22-
print('身份验证失败!')
20+
print('身份验证失败!')

Day01-15/Day04/code/for1.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
"""
2-
32
用for循环实现1~100求和
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-03-01
8-
97
"""
108

119
sum = 0
1210
for x in range(1, 101):
13-
if x % 2 == 0:
14-
sum += x
11+
if x % 2 == 0:
12+
sum += x
1513
print(sum)

Day01-15/Day04/code/for2.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""
2-
32
用for循环实现1~100之间的偶数求和
43
54
Version: 0.1
65
Author: 骆昊
76
Date: 2018-03-01
8-
97
"""
108

119
sum = 0
1210
for x in range(2, 101, 2):
13-
sum += x
11+
sum += x
1412
print(sum)

0 commit comments

Comments
 (0)