Skip to content

Commit

Permalink
update .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
liukai234 committed May 23, 2020
1 parent ec372e7 commit 6c95d59
Show file tree
Hide file tree
Showing 12 changed files with 470 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
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
Expand Down
16 changes: 16 additions & 0 deletions 圆圆的py/1.py
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是自动在元素之间补充的分隔字符
20 changes: 20 additions & 0 deletions 圆圆的py/2.py
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)
19 changes: 19 additions & 0 deletions 圆圆的py/creat_input.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* @Description:
* @LastEditors: liukai
* @Date: 2020-05-15 21:20:51
* @LastEditTime: 2020-05-15 21:24:27
* @FilePath: /pyFile/圆圆的py/creat_input.cpp
*/
#include <iostream>
using namespace std;

int main() {
for(int i = 1;i <= 10; i++) {
for(int j = 0; j < 4; j++) {
std::cout << i << " ";
}
std::cout << std::endl;
}
return 0;
}
26 changes: 26 additions & 0 deletions 圆圆的py/dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'''
@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]))
10 changes: 10 additions & 0 deletions 圆圆的py/input.txt
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
113 changes: 113 additions & 0 deletions 圆圆的py/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# 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)
29 changes: 29 additions & 0 deletions 圆圆的py/max_score.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'''
@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_index = ite

print("姓名:%s 学号: %s 成绩: %.1f" % (ite, name_dict[ite][0], name_dict[ite][1]))
43 changes: 43 additions & 0 deletions 圆圆的py/分支的嵌套结构.py
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)
38 changes: 38 additions & 0 deletions 圆圆的py/多分支结构.py
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)
Loading

0 comments on commit 6c95d59

Please sign in to comment.