forked from liukai234/python_course_record
-
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.
windows to linux, Merge branch 'master' of https://github.com/liukai2…
- Loading branch information
Showing
13 changed files
with
468 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# Ignore 圆圆的py folder | ||
圆圆的py/ | ||
# 圆圆的py/ | ||
|
||
# Ignore .idea folder | ||
.idea/ | ||
venv/ | ||
|
||
# Config by user | ||
test.py | ||
|
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
''' | ||
@Description: | ||
@LastEditors: liukai | ||
@Date: 2020-05-08 21:12:49 | ||
@LastEditTime: 2020-05-08 21:26:33 | ||
@FilePath: /pyFile/1.py | ||
''' | ||
|
||
# r = 3 | ||
r = float(input('r = ')) | ||
print(r) | ||
|
||
print(2 * 3.14 * r) | ||
|
||
# print("我是一行文本", a) | ||
# print('hello', 'python', sep=',', end='!\n') # sep是自动在元素之间补充的分隔字符 |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
''' | ||
@Description: | ||
@LastEditors: liukai | ||
@Date: 2020-05-08 21:54:57 | ||
@LastEditTime: 2020-05-09 10:08:11 | ||
@FilePath: /pyFile/2.py | ||
''' | ||
|
||
# sum = 0 | ||
# for x in range(10): | ||
# sum += x | ||
# print(sum) | ||
|
||
sum = 0 | ||
num = 1 | ||
while num < 10: | ||
sum += num | ||
num += 1 | ||
# num ++ # python不能 num ++ | ||
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
''' | ||
@Description: | ||
@LastEditors: liukai | ||
@Date: 2020-05-15 20:52:51 | ||
@LastEditTime: 2020-05-15 21:03:06 | ||
@FilePath: /pyFile/圆圆的py/dict.py | ||
''' | ||
|
||
name_dict = {} | ||
while True: | ||
info_list = [] | ||
name = input("姓名:") | ||
if name == "": | ||
break | ||
else: | ||
num = int(input("学号:")) | ||
info_list.append(num) | ||
score = float(input("成绩:")) | ||
info_list.append(score) | ||
name_dict[name] = info_list | ||
|
||
for key in name_dict: | ||
print("姓名:%s 学号: %s 成绩: %.1f" % (key, name_dict[key][0], name_dict[key][1])) | ||
|
||
find = input("输入查找姓名") | ||
if find in name_dict: | ||
print("姓名:%s 学号: %s 成绩: %.1f" % (find, name_dict[find][0], name_dict[find][1])) |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
1 1 1 1 | ||
2 2 2 2 | ||
3 3 3 3 | ||
4 4 4 4 | ||
5 5 5 5 | ||
6 6 6 6 | ||
7 7 7 7 | ||
8 8 8 8 | ||
9 9 9 9 | ||
10 10 10 10 |
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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# topic: 初学python之列表list | ||
# author:Liu Xiaoxia | ||
# time:2020/4/22 22:40 | ||
|
||
# 创建空列表 | ||
empty = [] | ||
print(empty) | ||
|
||
# 创建字符串列表 | ||
str_0 = ['abc', 'bcd', 'cde'] | ||
print(str_0) | ||
|
||
# str_0.append() | ||
# 创建数字列表 | ||
number = [1, 2, 3] | ||
print(number) | ||
|
||
# 创建混合列表 | ||
mix = ['abc', 2, 'def', 4] | ||
print(mix) | ||
|
||
# 在列表最后添加有且仅有一个元素 | ||
str_0.append('英语好难') | ||
print(str_0) | ||
len(str_0) | ||
|
||
# 用有且仅有一个列表扩展另一个列表,即同时在列表末尾添加多个元素 | ||
str_0.extend(['好好学习', '天天向上']) | ||
print(str_0) | ||
|
||
# 在列表固定位置(下标从0开始)插入元素 | ||
str_0.insert(0, 'aaaaa') | ||
print(str_0) | ||
|
||
# 从列表删除元素(方法) | ||
str_0.remove('英语好难') | ||
print(str_0) | ||
|
||
# 从列表删除元素(函数) | ||
del str_0[0] | ||
print(str_0) | ||
|
||
# 返回列表中要删除的元素值 | ||
# 删除最后一个元素 | ||
str_0.pop() | ||
print(str_0) | ||
# 删除指定元素 | ||
str_0.pop(1) | ||
print(str_0) | ||
|
||
|
||
# 列表切片(分片),一次性获取多个元素, 原列表不变 | ||
# 元素1到元素3(不包含元素3) | ||
print(str_0[1:3]) | ||
# 从列表头到元素3(不包含元素3) | ||
print(str_0[:3]) | ||
# 从元素3到列表末尾 | ||
print(str_0[3:]) | ||
# 输出整个列表 | ||
# 与str_1 = str_0不同 | ||
# str_1 = str_0时,str_0和str_1指向同一块空间;而str_0[:]仅仅是将值给了str_1一份,指向两块不同的空间 | ||
str_1 = str_0[:] | ||
print(str_1) | ||
|
||
# 拼接两个列表 | ||
str_0 = str_0 + number | ||
print(str_0) | ||
|
||
# 复制列表元素 | ||
# 复制后直接输出,原列表不变 | ||
print(number) | ||
print(number * 3) | ||
# 复制后赋值给原列表 | ||
number *= 2 | ||
print(number) | ||
|
||
# 判断元素是否在列表中 | ||
print('好好学习' in str_0) # true | ||
print('哈哈哈' not in str_0) # false | ||
|
||
# dosomething | ||
# 判断元素是否在列表中 | ||
# str_0.extend([['哈哈哈', 'wuwuwu']]) | ||
# print(str_0) | ||
# print('哈哈哈' in str_0) | ||
# print('哈哈哈' in str_0[len(str_0) - 1]) | ||
|
||
# 列表中的列表中的元素 | ||
# print(str_0[6][1]) | ||
|
||
# 列表中数据出现的次数 | ||
print(number.count(2)) | ||
|
||
# 返回参数在列表中第一次出现的位置 | ||
print(str_0.index('cde')) | ||
# 指定查找范围 | ||
print(str_0.index('cde', 0, 5)) | ||
|
||
# 将整个列表翻转(无参数) | ||
str_0.reverse() | ||
print(str_0) | ||
|
||
# sort排序 | ||
# 从小到大排序 | ||
number.sort() | ||
print(number) | ||
number.sort(reverse=False) | ||
print(number) | ||
# 从大到小排序 | ||
number.sort(reverse=True) | ||
print(number) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
''' | ||
@Description: | ||
@LastEditors: liukai | ||
@Date: 2020-05-15 21:02:38 | ||
@LastEditTime: 2020-05-15 21:10:20 | ||
@FilePath: /pyFile/圆圆的py/max_score.py | ||
''' | ||
|
||
name_dict = {} | ||
while True: | ||
info_list = [] | ||
name = input("姓名:") | ||
if name == "": | ||
break | ||
else: | ||
num = int(input("学号:")) | ||
info_list.append(num) | ||
score = float(input("成绩:")) | ||
info_list.append(score) | ||
name_dict[name] = info_list | ||
for key in name_dict: | ||
print("姓名:%s 学号: %s 成绩: %.1f" % (key, name_dict[key][0], name_dict[key][1])) | ||
|
||
max_score = 0 | ||
for ite in name_dict: | ||
if(name_dict[ite][1] > max_score): | ||
max_score = name_dict[ite][1] | ||
max_index = ite | ||
|
||
print("姓名:%s 学号: %s 成绩: %.1f" % (max_index, name_dict[max_index][0], name_dict[max_index][1])) |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
''' | ||
@Description: | ||
@LastEditors: liukai | ||
@Date: 2020-04-24 19:40:51 | ||
@LastEditTime: 2020-05-08 20:19:57 | ||
@FilePath: /pyFile/test.py | ||
''' | ||
# x = map (lambda x: x * x if x % 2 == 0 else 0 , range(10)) | ||
# print([y for y in x]) | ||
|
||
if __name__ == "__main__": | ||
list = [] | ||
for i in range(10): | ||
list.append(int(input())) | ||
list.sort(reverse=True) | ||
print(list[0:1]) | ||
|
||
def test(): | ||
print("Hello python") |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
''' | ||
@Description: 分支的嵌套结构 | ||
@LastEditors: liukai | ||
@Date: 2020-04-19 19:44:34 | ||
@LastEditTime: 2020-05-08 21:40:42 | ||
@FilePath: /pyFile/if-else/分支的嵌套结构.py | ||
''' | ||
|
||
#!/usr/bin/python3 | ||
a = int(input('a = ')) | ||
b = int(input('b = ')) | ||
c = int(input('c = ')) | ||
|
||
|
||
def printf(a, b): | ||
"print" | ||
print('maxValue is:', a, ' minValue is:', b) | ||
print(printf.__doc__) #输出函数注释 | ||
return 0 | ||
|
||
# 分支嵌套结构 | ||
if a > b: | ||
if b > c: | ||
print('a > b > c') | ||
printf(a, c) | ||
else: | ||
if a > c: | ||
print('a > c > b') | ||
printf(a, b) | ||
else: | ||
print('c > a > b') | ||
printf(c, b) | ||
else: | ||
if b < c: | ||
print('c > b > a') | ||
printf(c, a) | ||
else: | ||
if c > a: | ||
print('b > c > a') | ||
printf(b, a) | ||
else: | ||
print('b > a > c') | ||
printf(b, c) |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
''' | ||
@Description: 判断三个数的最大值和最小值 | ||
@LastEditors: liukai | ||
@Date: 2020-04-19 19:44:07 | ||
@LastEditTime: 2020-05-15 21:02:55 | ||
@FilePath: /pyFile/圆圆的py/多分支结构.py | ||
''' | ||
#!/usr/bin/python3 | ||
a = int(input('a = ')) | ||
b = int(input('b = ')) | ||
c = int(input('c = ')) | ||
|
||
def printf(a, b): | ||
"print" | ||
print('maxValue is:', a,' minValue is:', b); | ||
return 0 | ||
|
||
# 多分支结构即使用if-elif,类似C/C++分割中的switch-case语句 | ||
if a > b: | ||
if b > c: | ||
print('a > b > c') | ||
printf(a, c) | ||
elif a > c: | ||
print('a > c > b') | ||
printf(a, b) | ||
else: | ||
print('c > a > b') | ||
printf(c, b) | ||
elif a < b: | ||
if b < c: | ||
print('c > b > a') | ||
printf(c, a) | ||
elif c > a: | ||
print('b > c > a') | ||
printf(b, a) | ||
else: | ||
print('b > a > c') | ||
printf(b, c) |
Oops, something went wrong.