From c14708a9780d929160bfb0c4e8207fb2c8a7410a Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Mon, 14 Nov 2022 19:31:16 +0800
Subject: [PATCH 01/17] This is a test commit
---
zuozijun.txt | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 zuozijun.txt
diff --git a/zuozijun.txt b/zuozijun.txt
new file mode 100644
index 0000000..df82806
--- /dev/null
+++ b/zuozijun.txt
@@ -0,0 +1,2 @@
+左子俊
+2022204522
\ No newline at end of file
--
Gitee
From cf6688be142317ad5626344381fb12ab2c8465d5 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Mon, 14 Nov 2022 19:56:51 +0800
Subject: [PATCH 02/17] homework_python1
---
homework_01_python/homework_python1.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 homework_01_python/homework_python1.py
diff --git a/homework_01_python/homework_python1.py b/homework_01_python/homework_python1.py
new file mode 100644
index 0000000..06bb05d
--- /dev/null
+++ b/homework_01_python/homework_python1.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Nov 14 19:38:35 2022
+
+@author: Zuo zijun
+"""
+list1="One is always on a strange road, watching strange scenery and listening to \
+strange music. Then one day, you will find that the things you try hard to forget \
+are already gone. "
+dict={}
+keys=list1.split()
+for key in keys:
+ if key in dict.keys():
+ dict[key]+=1
+ else:
+ dict[key]=1
+print(dict)
\ No newline at end of file
--
Gitee
From 95f8afd38fe7147e4f91ca959e25128f914f1c11 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Mon, 14 Nov 2022 20:18:25 +0800
Subject: [PATCH 03/17] homework_python2
---
homework_01_python/homework_python2.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 homework_01_python/homework_python2.py
diff --git a/homework_01_python/homework_python2.py b/homework_01_python/homework_python2.py
new file mode 100644
index 0000000..700bf98
--- /dev/null
+++ b/homework_01_python/homework_python2.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Nov 14 20:04:12 2022
+
+@author: Zuo zijun
+"""
+
+
+number=0;
+for a in range(1,5):
+ for b in range(1,5):
+ for c in range(1,5):
+ if a!=b & a!=c & b!=c:
+ print(a*100+b*10+c);
+ number=number+1;
+print('组成不相同且无重复数字的个数为',number)
\ No newline at end of file
--
Gitee
From 1422bc7a15e32dd5cd288c99a5877dc257dc36c4 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Mon, 14 Nov 2022 20:56:36 +0800
Subject: [PATCH 04/17] homework_python3
---
homework_01_python/homework_python3.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 homework_01_python/homework_python3.py
diff --git a/homework_01_python/homework_python3.py b/homework_01_python/homework_python3.py
new file mode 100644
index 0000000..b23e998
--- /dev/null
+++ b/homework_01_python/homework_python3.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Nov 14 20:19:32 2022
+
+@author: Zuo zijun
+"""
+
+jj=eval(input("请输入当月利润(万元):"))
+lr=0;
+if jj<=10:
+ lr=jj*0.1
+elif jj>10 and jj<=20:
+ lr=10*0.1+(jj-10)*0.075
+elif jj>20 and jj<=40:
+ lr=(jj-20)*0.05
+elif jj>40 and jj<=60:
+ lr=(jj-40)*0.03
+elif jj>60 and jj<=100:
+ lr=(jj-60)*0.015
+elif jj>100:
+ lr=(jj-100)*0.01
+print("当月应发奖金%.*f万元"%(3,lr))
\ No newline at end of file
--
Gitee
From 6a3b1d44c37fb97c77d2e9a04823b208f19204ce Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Mon, 14 Nov 2022 21:19:30 +0800
Subject: [PATCH 05/17] homework_python4
---
homework_01_python/homework_python4.py | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 homework_01_python/homework_python4.py
diff --git a/homework_01_python/homework_python4.py b/homework_01_python/homework_python4.py
new file mode 100644
index 0000000..d34197b
--- /dev/null
+++ b/homework_01_python/homework_python4.py
@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Nov 14 20:58:25 2022
+
+@author: Zuo zijun
+"""
+
+for i in range(10):
+ for j in range(10):
+ cj=i*j;
+ print(f"{i}x{j}={cj}")
\ No newline at end of file
--
Gitee
From 9e5c703470af2b3ac7c1226517102e31b7f698eb Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 10:08:57 +0800
Subject: [PATCH 06/17] homework_python5
---
homework_01_python/homework_python4.py | 4 +++-
homework_01_python/homework_python5.py | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 homework_01_python/homework_python5.py
diff --git a/homework_01_python/homework_python4.py b/homework_01_python/homework_python4.py
index d34197b..dc4a85f 100644
--- a/homework_01_python/homework_python4.py
+++ b/homework_01_python/homework_python4.py
@@ -7,5 +7,7 @@ Created on Mon Nov 14 20:58:25 2022
for i in range(10):
for j in range(10):
- cj=i*j;
+ if i==9:
+ print()\
+ else: cj=i*j;
print(f"{i}x{j}={cj}")
\ No newline at end of file
diff --git a/homework_01_python/homework_python5.py b/homework_01_python/homework_python5.py
new file mode 100644
index 0000000..c3bfe7d
--- /dev/null
+++ b/homework_01_python/homework_python5.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 09:02:45 2022
+
+@author: Zuo zijun
+"""
+
+a=2
+sum=0
+while a<=100:
+ if a%2==0:
+ sum=sum+a
+ elif a%2==1:
+ sum=sum-a
+ a+=1
+print("sum={}".format(sum))
\ No newline at end of file
--
Gitee
From 9b208a485a640b5dad51c0ea4b15c11e457cf791 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 10:11:11 +0800
Subject: [PATCH 07/17] homework-python4
---
homework_01_python/homework_python4.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/homework_01_python/homework_python4.py b/homework_01_python/homework_python4.py
index dc4a85f..967780e 100644
--- a/homework_01_python/homework_python4.py
+++ b/homework_01_python/homework_python4.py
@@ -4,7 +4,6 @@ Created on Mon Nov 14 20:58:25 2022
@author: Zuo zijun
"""
-
for i in range(10):
for j in range(10):
if i==9:
--
Gitee
From 91bb2f774827ddf688cfdfd1e4e0172894c88855 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 15:08:09 +0800
Subject: [PATCH 08/17] homework_python6
---
homework_01_python/homework_python6.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 homework_01_python/homework_python6.py
diff --git a/homework_01_python/homework_python6.py b/homework_01_python/homework_python6.py
new file mode 100644
index 0000000..4028124
--- /dev/null
+++ b/homework_01_python/homework_python6.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 10:12:22 2022
+
+@author: Zuo zijun
+"""
+
+old_list=[1,10,4,2,9,2,34,5,9,8,5,0]
+new_list=[]
+for i in range(11,1,-1):
+ smallest=old_list[0]
+ for j in range(1,i):
+ if smallest<=old_list[j]:
+ pass
+ else:
+ smallest=old_list[j]
+ old_list.remove(smallest)
+ new_list.append(smallest)
+new_list.append(old_list[0])
+print(new_list)
\ No newline at end of file
--
Gitee
From 062e4876fdc275c8cf337d904a223fb807e7a17f Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 15:35:56 +0800
Subject: [PATCH 09/17] homework_python7
---
homework_01_python/homework_python7.py | 28 ++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 homework_01_python/homework_python7.py
diff --git a/homework_01_python/homework_python7.py b/homework_01_python/homework_python7.py
new file mode 100644
index 0000000..19cc503
--- /dev/null
+++ b/homework_01_python/homework_python7.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 15:19:24 2022
+
+@author: Zuo zijun
+"""
+
+def searchMatrix(matrix,target):
+ target = eval(input("请输入目标值:"))
+ matrix = eval(input("请输入矩阵:"))
+ if not matrix:
+ return False
+ row=len(matrix)
+ col=len(matrix[0])
+ i=row-1
+ j=0
+ judge=False
+ while(i>=0) or (j
(col-1):
+ break
+ if matrix[i][j]>target:
+ i=i-1
+ elif matrix[i][j]
Date: Sat, 19 Nov 2022 15:42:50 +0800
Subject: [PATCH 10/17] homework_python8
---
homework_01_python/homework_python8.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 homework_01_python/homework_python8.py
diff --git a/homework_01_python/homework_python8.py b/homework_01_python/homework_python8.py
new file mode 100644
index 0000000..2fb4a85
--- /dev/null
+++ b/homework_01_python/homework_python8.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 15:36:02 2022
+
+@author: Zuo zijun
+"""
+wanmeishu_list=[]
+for i in range(1000):
+ s=0
+ for j in range(1,i-1):
+ if i % j == 0:
+ s=s+j
+ if i==s:
+ wanmeishu_list.append(i)
+
+print (wanmeishu_list)
+
\ No newline at end of file
--
Gitee
From bf5b7a7a7154418eea53591ffa8fa544191d6b04 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 15:55:43 +0800
Subject: [PATCH 11/17] homework_python9
---
homework_01_python/homework_python9.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 homework_01_python/homework_python9.py
diff --git a/homework_01_python/homework_python9.py b/homework_01_python/homework_python9.py
new file mode 100644
index 0000000..8fb89fe
--- /dev/null
+++ b/homework_01_python/homework_python9.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 15:42:56 2022
+
+@author: Zuo zijun
+"""
+
+def HappyNumber(num):
+ numStr=str(num)
+ digitals=[int(x) for x in numStr]
+ sum=0
+ for i in digitals:
+ sum+=i**2
+ return sum
+n=eval(input("please input a number:"))
+count=0
+while n!=1:
+ n=HappyNumber(n)
+ count+=1
+ if count>1000:
+ print("False")
+ break
+else:
+ print("True")
\ No newline at end of file
--
Gitee
From a6df0166bceecb2a47adaaf2ed140e61c4aaec14 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:33:10 +0800
Subject: [PATCH 12/17] homework_python10
---
homework_01_python/homework_python10.py | 29 +++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 homework_01_python/homework_python10.py
diff --git a/homework_01_python/homework_python10.py b/homework_01_python/homework_python10.py
new file mode 100644
index 0000000..94f531f
--- /dev/null
+++ b/homework_01_python/homework_python10.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:14:33 2022
+
+@author: Zuo zijun
+"""
+
+def existnumber(num, x):
+ for i in range(len(num)-1):
+ for j in range(i+1, len(num)):
+ sum = 0;
+ for k in range(i, j+1):
+ sum = sum + num[k]
+ if sum % x == 0 :
+ return True
+ else:
+ pass
+
+sz = input("请以x1,x2,...,xn形式输入数组:")
+stra = sz.split(',')
+a = []
+for x in stra:
+ a.append(int(x))
+print(a)
+number = int(input("请输入数字:"))
+if existnumber(a, number):
+ print("true")
+else:
+ print("false")
\ No newline at end of file
--
Gitee
From 6fd1ef60dc728018c3488ee7df1df681887071a2 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:35:39 +0800
Subject: [PATCH 13/17] homework_python11
---
homework_01_python/homework_python11.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 homework_01_python/homework_python11.py
diff --git a/homework_01_python/homework_python11.py b/homework_01_python/homework_python11.py
new file mode 100644
index 0000000..a1b1d18
--- /dev/null
+++ b/homework_01_python/homework_python11.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:33:48 2022
+
+@author: Zuo zijun
+"""
+
+def isunique(astr):
+ if len(astr)==len(set(astr)):
+ print ("True")
+ else:
+ print ("False")
+str1=input("please input a string:")
+isunique(str1)
\ No newline at end of file
--
Gitee
From 0fc721c57b0fd8ae59b504f6320f62c927384f41 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:37:22 +0800
Subject: [PATCH 14/17] homework_python12
---
homework_01_python/homework_python12.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 homework_01_python/homework_python12.py
diff --git a/homework_01_python/homework_python12.py b/homework_01_python/homework_python12.py
new file mode 100644
index 0000000..cd5b668
--- /dev/null
+++ b/homework_01_python/homework_python12.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:36:00 2022
+
+@author: Zuo zijun
+"""
+
+astr=input("please input a string:")
+count_b=astr.count('b')
+count_a=astr.count('a')
+count_l=astr.count('l')//2
+count_o=astr.count('o')//2
+count_n=astr.count('n')
+print(min(count_b,count_a,count_l,count_o,count_n))
\ No newline at end of file
--
Gitee
From bae44e2a65ab5b6d114fcb09074ee501d82ddf4a Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:38:22 +0800
Subject: [PATCH 15/17] homework_python13
---
homework_01_python/homework_python13.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 homework_01_python/homework_python13.py
diff --git a/homework_01_python/homework_python13.py b/homework_01_python/homework_python13.py
new file mode 100644
index 0000000..e00b25e
--- /dev/null
+++ b/homework_01_python/homework_python13.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:37:29 2022
+
+@author: Zuo zijun
+"""
+
+import random
+list1=[]
+for x in range(65,91):
+ a=str(chr(x))
+ list1.append(a)
+for x in range(97,123):
+ b=str(chr(x))
+ list1.append(b)
+for x in range(10):
+ list1.append(str(x))
+def gen_code():
+ s=''
+ for x in range(11):
+ a=random.choice(list1)
+ s+=a
+ print(s)
+for x in range(200):
+ gen_code()
\ No newline at end of file
--
Gitee
From c54e9c67b7a4de83c8346ce249cd8179cd7776fa Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:39:41 +0800
Subject: [PATCH 16/17] homework_python14
---
homework_01_python/homework_python14.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 homework_01_python/homework_python14.py
diff --git a/homework_01_python/homework_python14.py b/homework_01_python/homework_python14.py
new file mode 100644
index 0000000..ff02eb5
--- /dev/null
+++ b/homework_01_python/homework_python14.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:38:46 2022
+
+@author: Zuo zijun
+"""
+
+import os
+def get_files(dir,suffix):
+ res=[]
+ for root,directory,files in os.walk(dir):
+ for filename in files:
+ name, suf = os.path.splitext(filename)
+ if suf == suffix:
+ res.append(os.path.join(root,filename))
+ return res
+for file in get_files("./",'.dll'):
+ print(file)
\ No newline at end of file
--
Gitee
From f9acb34d4b4e5efc7b9b77f1ffc142f717e70ba1 Mon Sep 17 00:00:00 2001
From: zuozijun <2418710689@qq.com>
Date: Sat, 19 Nov 2022 16:42:24 +0800
Subject: [PATCH 17/17] homework_python15
---
homework_01_python/homework_python15.py | 60 +++++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 homework_01_python/homework_python15.py
diff --git a/homework_01_python/homework_python15.py b/homework_01_python/homework_python15.py
new file mode 100644
index 0000000..3f608d9
--- /dev/null
+++ b/homework_01_python/homework_python15.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Sat Nov 19 16:40:00 2022
+
+@author: Zuo zijun
+"""
+
+import os
+
+
+def get_all_file(path):
+ file_list = []
+ for file in os.listdir(path):
+ if os.path.splitext(file)[1]=='.py':
+ file_list.append(path +'/'+file)
+ print('添加',file)
+ return file_list
+
+
+def get_rows(file):
+ with open(file,encoding='utf8') as f:
+ lines = f.readline()
+ rows = len(lines)
+ vv =0
+ space =0
+ for line in lines:
+ if line =='\n':
+ space +=1
+ if line[0]=="#":
+ vv+=1
+ date ={
+ 'rows':rows,
+ 'vv':vv,
+ 'space':space
+ }
+ return date
+
+
+def run(path):
+ file_list = get_all_file(path)
+
+ all_rows =0
+ all_vuui=0
+ all_space= 0
+
+ for file in file_list:
+ date = get_rows(file)
+ print("正在计算",file)
+ rows = date.get( 'rows')
+ vv = date.get('vv')
+ space = date.get('space')
+ all_rows += rows
+ all_space +=space
+ all_vuui +=vv
+ print('所有代码的行数:{}\n其中包括的注释行数:{}\n其中空格行数:{}'.format(all_rows, all_vuui, all_space))
+
+
+if __name__ =='__main__':
+ path = 'C:\\Users\\Zuo zijun\\machinelearning_homework\\homework_01_python'
+ run(path=path)
\ No newline at end of file
--
Gitee