Skip to content

Commit

Permalink
更正了部分文档和代码
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrued committed May 3, 2019
1 parent 28067bf commit 6411875
Show file tree
Hide file tree
Showing 128 changed files with 1,484 additions and 1,709 deletions.
2 changes: 0 additions & 2 deletions Day01-15/Day01/code/hello.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
第一个Python程序 - hello, world!
向伟大的Dennis M. Ritchie先生致敬
Expand All @@ -9,7 +8,6 @@
请将该文件命名为hello.py并在终端中通过下面的命令运行它
python hello.py
"""

print('hello, world!')
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/centigrade.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
将华氏温度转换为摄氏温度
F = 1.8C + 32
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

f = float(input('请输入华氏温度: '))
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/circle.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
输入半径计算圆的周长和面积
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

import math
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/leap.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
输入年份 如果是闰年输出True 否则输出False
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

year = int(input('请输入年份: '))
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/operator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
运算符的使用
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = 5
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/string.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
字符串常用操作
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

str1 = 'hello, world!'
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/variable1.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
使用变量保存数据并进行操作
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = 321
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/variable2.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
将input函数输入的数据保存在变量中并进行操作
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = int(input('a = '))
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/variable3.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
格式化输出
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = int(input('a = '))
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/variable4.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
检查变量的类型
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = 100
Expand Down
2 changes: 0 additions & 2 deletions Day01-15/Day02/code/variable5.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
类型转换
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""

a = 100
Expand Down
Empty file removed Day01-15/Day03/.py
Empty file.
8 changes: 3 additions & 5 deletions Day01-15/Day03/code/convert.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
"""
英制单位英寸和公制单位厘米互换
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

value = float(input('请输入长度: '))
unit = input('请输入单位: ')
if unit == 'in' or unit == '英寸':
print('%f英寸 = %f厘米' % (value, value * 2.54))
print('%f英寸 = %f厘米' % (value, value * 2.54))
elif unit == 'cm' or unit == '厘米':
print('%f厘米 = %f英寸' % (value, value / 2.54))
print('%f厘米 = %f英寸' % (value, value / 2.54))
else:
print('请输入有效的单位')
print('请输入有效的单位')
22 changes: 10 additions & 12 deletions Day01-15/Day03/code/grade.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
"""
百分制成绩转等级制成绩
90分以上 --> A
80分~89分 --> B
70分~79分 --> C
60分~69分 --> D
60分以下 --> E
90分以上 --> A
80分~89分 --> B
70分~79分 --> C
60分~69分 --> D
60分以下 --> E
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

score = float(input('请输入成绩: '))
if score >= 90:
grade = 'A'
grade = 'A'
elif score >= 80:
grade = 'B'
grade = 'B'
elif score >= 70:
grade = 'C'
grade = 'C'
elif score >= 60:
grade = 'D'
grade = 'D'
else:
grade = 'E'
grade = 'E'
print('对应的等级是:', grade)
14 changes: 6 additions & 8 deletions Day01-15/Day03/code/piecewise.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
"""
分段函数求值
3x - 5 (x > 1)
f(x) = x + 2 (-1 <= x <= 1)
5x + 3 (x < -1)
3x - 5 (x > 1)
f(x) = x + 2 (-1 <= x <= 1)
5x + 3 (x < -1)
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

x = float(input('x = '))
if x > 1:
y = 3 * x - 5
y = 3 * x - 5
elif x >= -1:
y = x + 2
y = x + 2
else:
y = 5 * x + 3
y = 5 * x + 3
print('f(%.2f) = %.2f' % (x, y))
14 changes: 6 additions & 8 deletions Day01-15/Day03/code/rolldice.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
"""
掷骰子决定做什么事情
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

from random import randint

face = randint(1, 6)
if face == 1:
result = '唱首歌'
result = '唱首歌'
elif face == 2:
result = '跳个舞'
result = '跳个舞'
elif face == 3:
result = '学狗叫'
result = '学狗叫'
elif face == 4:
result = '做俯卧撑'
result = '做俯卧撑'
elif face == 5:
result = '念绕口令'
result = '念绕口令'
else:
result = '讲冷笑话'
result = '讲冷笑话'
print(result)
35 changes: 17 additions & 18 deletions Day01-15/Day03/code/tax.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
"""
输入月收入和五险一金计算个人所得税
说明:写这段代码时新的个人所得税计算方式还没有颁布
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

salary = float(input('本月收入: '))
insurance = float(input('五险一金: '))
diff = salary - insurance - 3500
if diff <= 0:
rate = 0
deduction = 0
rate = 0
deduction = 0
elif diff < 1500:
rate = 0.03
deduction = 0
rate = 0.03
deduction = 0
elif diff < 4500:
rate = 0.1
deduction = 105
rate = 0.1
deduction = 105
elif diff < 9000:
rate = 0.2
deduction = 555
rate = 0.2
deduction = 555
elif diff < 35000:
rate = 0.25
deduction = 1005
rate = 0.25
deduction = 1005
elif diff < 55000:
rate = 0.3
deduction = 2755
rate = 0.3
deduction = 2755
elif diff < 80000:
rate = 0.35
deduction = 5505
rate = 0.35
deduction = 5505
else:
rate = 0.45
deduction = 13505
rate = 0.45
deduction = 13505
tax = abs(diff * rate - deduction)
print('个人所得税: ¥%.2f元' % tax)
print('实际到手收入: ¥%.2f元' % (diff + 3500 - tax))
12 changes: 5 additions & 7 deletions Day01-15/Day03/code/triangle.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
判断输入的边长能否构成三角形
如果能则计算出三角形的周长和面积
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

import math
Expand All @@ -15,9 +13,9 @@
b = float(input('b = '))
c = float(input('c = '))
if a + b > c and a + c > b and b + c > a:
print('周长: %f' % (a + b + c))
p = (a + b + c) / 2
area = math.sqrt(p * (p - a) * (p - b) * (p - c))
print('面积: %f' % (area))
print('周长: %f' % (a + b + c))
p = (a + b + c) / 2
area = math.sqrt(p * (p - a) * (p - b) * (p - c))
print('面积: %f' % (area))
else:
print('不能构成三角形')
print('不能构成三角形')
6 changes: 2 additions & 4 deletions Day01-15/Day03/code/verify.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
用户身份验证
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""

# import getpass
Expand All @@ -17,6 +15,6 @@
# 输入口令的时候终端中没有回显
# password = getpass.getpass('请输入口令: ')
if username == 'admin' and password == '123456':
print('身份验证成功!')
print('身份验证成功!')
else:
print('身份验证失败!')
print('身份验证失败!')
6 changes: 2 additions & 4 deletions Day01-15/Day04/code/for1.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""
用for循环实现1~100求和
Version: 0.1
Author: 骆昊
Date: 2018-03-01
"""

sum = 0
for x in range(1, 101):
if x % 2 == 0:
sum += x
if x % 2 == 0:
sum += x
print(sum)
4 changes: 1 addition & 3 deletions Day01-15/Day04/code/for2.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"""
用for循环实现1~100之间的偶数求和
Version: 0.1
Author: 骆昊
Date: 2018-03-01
"""

sum = 0
for x in range(2, 101, 2):
sum += x
sum += x
print(sum)
Loading

0 comments on commit 6411875

Please sign in to comment.