forked from jackfrued/Python-100-Days
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
1,484 additions
and
1,709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('请输入华氏温度: ')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
输入半径计算圆的周长和面积 | ||
Version: 0.1 | ||
Author: 骆昊 | ||
Date: 2018-02-27 | ||
""" | ||
|
||
import math | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('请输入年份: ')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
运算符的使用 | ||
Version: 0.1 | ||
Author: 骆昊 | ||
Date: 2018-02-27 | ||
""" | ||
|
||
a = 5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
使用变量保存数据并进行操作 | ||
Version: 0.1 | ||
Author: 骆昊 | ||
Date: 2018-02-27 | ||
""" | ||
|
||
a = 321 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
检查变量的类型 | ||
Version: 0.1 | ||
Author: 骆昊 | ||
Date: 2018-02-27 | ||
""" | ||
|
||
a = 100 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
类型转换 | ||
Version: 0.1 | ||
Author: 骆昊 | ||
Date: 2018-02-27 | ||
""" | ||
|
||
a = 100 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('请输入有效的单位') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.