From cd4060d938a660f6def60565a67ad3860edd4557 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 17 Aug 2019 12:32:00 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E8=87=AA=E5=AD=A6=E8=AE=AD=E7=BB=83?= =?UTF-8?q?=E8=90=A5=E5=AD=A6=E4=B9=A020=E7=BE=A4=20=E5=AD=A6=E5=8F=B71901?= =?UTF-8?q?10304day1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercises/190110304/1001S02E01_helloworld.txt | 1 + exercises/190110304/README.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 exercises/190110304/1001S02E01_helloworld.txt create mode 100644 exercises/190110304/README.md diff --git a/exercises/190110304/1001S02E01_helloworld.txt b/exercises/190110304/1001S02E01_helloworld.txt new file mode 100644 index 000000000..44da59296 --- /dev/null +++ b/exercises/190110304/1001S02E01_helloworld.txt @@ -0,0 +1 @@ + 1001S02E01_helloworld.txt {\rtf1} \ No newline at end of file diff --git a/exercises/190110304/README.md b/exercises/190110304/README.md new file mode 100644 index 000000000..08778d7a8 --- /dev/null +++ b/exercises/190110304/README.md @@ -0,0 +1 @@ +{\rtf1} \ No newline at end of file From d8971384796798260db171e5b2382f1b69f0018c Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 17 Aug 2019 12:38:44 +0800 Subject: [PATCH 02/12] 190110304day1 --- exercises/190110304/1001S02E01_helloworld.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/190110304/1001S02E01_helloworld.txt b/exercises/190110304/1001S02E01_helloworld.txt index 44da59296..dce502cab 100644 --- a/exercises/190110304/1001S02E01_helloworld.txt +++ b/exercises/190110304/1001S02E01_helloworld.txt @@ -1 +1 @@ - 1001S02E01_helloworld.txt {\rtf1} \ No newline at end of file +大家好 我叫刘新晨来自吉林 \ No newline at end of file From 06b7eadcb285a7ead3dab7f11bd7646720b75535 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 17 Aug 2019 12:44:03 +0800 Subject: [PATCH 03/12] =?UTF-8?q?190110304=E8=87=AA=E5=AD=A6=E8=AE=AD?= =?UTF-8?q?=E7=BB=83=E8=90=A5=E5=AD=A6=E4=B9=A020=E7=BE=A4day1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercises/190110304/1001S02E01_helloworld.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/190110304/1001S02E01_helloworld.txt b/exercises/190110304/1001S02E01_helloworld.txt index dce502cab..c39d78c3c 100644 --- a/exercises/190110304/1001S02E01_helloworld.txt +++ b/exercises/190110304/1001S02E01_helloworld.txt @@ -1 +1 @@ -大家好 我叫刘新晨来自吉林 \ No newline at end of file +大家好我是刘新晨,来自吉林 \ No newline at end of file From 9713c23808ff093bf86465ff9c63ed44c70b1b1e Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 17 Aug 2019 17:26:57 +0800 Subject: [PATCH 04/12] Create 1001S02E02_hello_python.py --- exercises/190110304/1001S02E02_hello_python.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 exercises/190110304/1001S02E02_hello_python.py diff --git a/exercises/190110304/1001S02E02_hello_python.py b/exercises/190110304/1001S02E02_hello_python.py new file mode 100644 index 000000000..e75154b7c --- /dev/null +++ b/exercises/190110304/1001S02E02_hello_python.py @@ -0,0 +1 @@ +print("hello world") \ No newline at end of file From 51acf54c2b1bff51ea33978394ef6447c06fa974 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Mon, 19 Aug 2019 11:14:52 +0800 Subject: [PATCH 05/12] Create 1001S02E03_calculator.py --- exercises/190110304/1001S02E03_calculator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 exercises/190110304/1001S02E03_calculator.py diff --git a/exercises/190110304/1001S02E03_calculator.py b/exercises/190110304/1001S02E03_calculator.py new file mode 100644 index 000000000..98dddecf9 --- /dev/null +++ b/exercises/190110304/1001S02E03_calculator.py @@ -0,0 +1,18 @@ + +# This is a python language calculator + +operator = input('Please enter an operator (+, -, *, /) : ') + +a = int(first_number) +b = int(second_number) + +if operator == '+': + print(a, '+', b, '=', a + b) +elif operator == '-': + print(a, '-', b, '=', a - b) +elif operator == '*': + print(a, '*', b, '=', a * b) +elif operator == '/': + print(a, '/', b, '=', a / b) +else: + print('Null operator') \ No newline at end of file From b0de0e7b78631bdfeb888cfe0c9c78b5a0f64612 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 24 Aug 2019 16:09:09 +0800 Subject: [PATCH 06/12] Create 1001S02E04_control_flow.py --- .../190110304/1001S02E04_control_flow.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 exercises/190110304/1001S02E04_control_flow.py diff --git a/exercises/190110304/1001S02E04_control_flow.py b/exercises/190110304/1001S02E04_control_flow.py new file mode 100644 index 000000000..a9866537c --- /dev/null +++ b/exercises/190110304/1001S02E04_control_flow.py @@ -0,0 +1,20 @@ +for i in range(1,10,2): #i是一个临时变量 range(1,10)从1打印到10 + for j in range(1,10): #j是一个临时变量 range(1,10)从1打印到10 + print(j,"x",i,"=",i*j,"\t",end="") #i和j相乘 end是空行 + if i==j: #换行 + print("") + break + + + +i = 1 #第一个计数器 +while i <10: + j = 1#第二个计数器 + while j <= i: + print('%dx%d=%d\t' %(j, i, i*j) , end=('')) + j +=1 + print('') #换行 + i +=1 +print('')#输出换 + + \ No newline at end of file From 659bc10bb919d8fafa72991ced98d39133af1cd5 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 24 Aug 2019 16:14:23 +0800 Subject: [PATCH 07/12] Update 1001S02E04_control_flow.py --- exercises/190110304/1001S02E04_control_flow.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/190110304/1001S02E04_control_flow.py b/exercises/190110304/1001S02E04_control_flow.py index a9866537c..3e00e7d23 100644 --- a/exercises/190110304/1001S02E04_control_flow.py +++ b/exercises/190110304/1001S02E04_control_flow.py @@ -15,6 +15,5 @@ j +=1 print('') #换行 i +=1 -print('')#输出换 - +print('')#输出换行 \ No newline at end of file From 8a52ac93f81c93e934f502a57cc435bfff53fe27 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 24 Aug 2019 16:19:16 +0800 Subject: [PATCH 08/12] Update 1001S02E04_control_flow.py --- exercises/190110304/1001S02E04_control_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/190110304/1001S02E04_control_flow.py b/exercises/190110304/1001S02E04_control_flow.py index 3e00e7d23..ca00839c8 100644 --- a/exercises/190110304/1001S02E04_control_flow.py +++ b/exercises/190110304/1001S02E04_control_flow.py @@ -15,5 +15,5 @@ j +=1 print('') #换行 i +=1 -print('')#输出换行 +print('')#输出换行 \ No newline at end of file From 4c96a5313a721b84a23b06d503c0518f58a72b3f Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Sat, 24 Aug 2019 16:21:32 +0800 Subject: [PATCH 09/12] Update 1001S02E04_control_flow.py --- exercises/190110304/1001S02E04_control_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/190110304/1001S02E04_control_flow.py b/exercises/190110304/1001S02E04_control_flow.py index ca00839c8..34fe6fb17 100644 --- a/exercises/190110304/1001S02E04_control_flow.py +++ b/exercises/190110304/1001S02E04_control_flow.py @@ -16,4 +16,4 @@ print('') #换行 i +=1 print('')#输出换行 - \ No newline at end of file + \ No newline at end of file From c778d53e8b1ddbdb4244824c6d00c58878ed2364 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Thu, 19 Sep 2019 19:06:16 +0800 Subject: [PATCH 10/12] Create 1001S02E05_string.py --- exercises/190110304/1001S02E05_stats_text.py | 32 +++++++++++++ exercises/190110304/1001S02E05_string.py | 50 ++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 exercises/190110304/1001S02E05_stats_text.py create mode 100644 exercises/190110304/1001S02E05_string.py diff --git a/exercises/190110304/1001S02E05_stats_text.py b/exercises/190110304/1001S02E05_stats_text.py new file mode 100644 index 000000000..2c9e805d8 --- /dev/null +++ b/exercises/190110304/1001S02E05_stats_text.py @@ -0,0 +1,32 @@ + +text=(''' +The Zen of Python, by Tim Peters +Beautiful is better than ugly. +Explicit is better than implicit. +Simple is better than complex. +Complex is better than complicated. +Flat is better than nested. +Sparse is better than dense. +Readability counts. +Special cases aren't special enough to break the rules. +Although practicality beats purity. +Errors should never pass silently. +Unless explicitly silenced. +In the face of ambxiguity, refuse the temptation to guess. +There should be one-- and preferably only one --obvious way to do +it. +Although that way may not be obvious at first unless you're Dutch. +Now is better than never. +Although never is often better than *right* now. +If the implementation is hard to explain, it's a bad idea. +If the implementation is easy to explain, it may be a good idea. +Namespaces are one honking great idea -- let's do more of those!''') +text1=text.split()#将字符串转换成列表 +text2={} #创建字典 +for i in text1: #for是发起循环的关键词;i in text1是循环规则,i是依次得到txet1列表中的各个值,然后按照索引顺序循环下去,直到最后一个 + if i in text2: + text2[i]=text2[i]+1 #统计单词出现的次数 + else: + text2[i]=1 +print(text2) + diff --git a/exercises/190110304/1001S02E05_string.py b/exercises/190110304/1001S02E05_string.py new file mode 100644 index 000000000..e56ff1afa --- /dev/null +++ b/exercises/190110304/1001S02E05_string.py @@ -0,0 +1,50 @@ +import re # 正则表达式 +text=('''The Zen of Python, by Tim Peters +Beautiful is better than ugly. +Explicit is better than implicit. +Simple is better than complex. +Complex is better than complicated. +Flat is better than nested. +Sparse is better than dense. +Readability counts. +Special cases aren't special enough to break the rules. +Although practicality beats purity. +Errors should never pass silently. +Unless explicitly silenced. +In the face of ambxiguity, refuse the temptation to guess. +There should be one-- and preferably only one --obvious way to do +it. +Although that way may not be obvious at first unless you're Dutch. +Now is better than never. +Although never is often better than *right* now. +If the implementation is hard to explain, it's a bad idea. +If the implementation is easy to explain, it may be a good idea. +Namespaces are one honking great idea -- let's do more of those!''') + + +text2=text.replace("better","worse") #用replace将文本中 better 全部替换成 worse +print (text2) + +text3=text.split() #split将字符串转换成列表 +print (text3) + +text4 = [] + +for i in text3: #for是发起循环的关键词;i in text3是循环规则,i是依次得到txet3列表中的各个值,然后按照索引顺序循环下去,直到最后一个 + if i.find("ea") < 0: #这个if语句是判断“ea"是不是在某个单词里面 + text4.append(i) + print (text4) + +text5=text.swapcase()#用swapcase将文本中的大小写字母进行互换 +print(text5) + +text6=text3.sort() #先用split将字符串改成列表形式 然后再用sort进行排序 这里用text3是因为 text3是已经转变完成的列表 +print(text3) + + + + + + + + From 4d3396a57992db2793aac638a10ceedfb7987f0a Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Thu, 19 Sep 2019 19:06:24 +0800 Subject: [PATCH 11/12] Create 1001S02E05_array.py --- exercises/190110304/1001S02E05_array.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 exercises/190110304/1001S02E05_array.py diff --git a/exercises/190110304/1001S02E05_array.py b/exercises/190110304/1001S02E05_array.py new file mode 100644 index 000000000..8001d59d9 --- /dev/null +++ b/exercises/190110304/1001S02E05_array.py @@ -0,0 +1,19 @@ +a=[0,1, 2, 3, 4, 5, 6, 7, 8, 9] +a=a[::-1]#将数组反转 +print(a) +str = ''.join(str(i) for i in a) #将数组转换成字串符 +print(str) + +b=str[2:8] #⽤字符串切⽚的⽅式取出第三到第⼋个字符 +print(b) + +b=b[::-1]#将取出的结果反转 +print(b) + +c=int(b)#将结果转换为 int 类型 +print(c) + +#分别转换成⼆二进制,⼋八进制,⼗十六进制,最后输出三种进制的结果 +print('二进制:',bin(c)) +print('八进制:',oct(c)) +print('十六进制:',hex(c)) From 35a79e60b39fe017ed20d35716763362dea0daa1 Mon Sep 17 00:00:00 2001 From: xing-cheng <54171952+xing-cheng@users.noreply.github.com> Date: Thu, 19 Sep 2019 19:08:41 +0800 Subject: [PATCH 12/12] Update 1001S02E02_hello_python.py --- exercises/190110304/1001S02E02_hello_python.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/exercises/190110304/1001S02E02_hello_python.py b/exercises/190110304/1001S02E02_hello_python.py index e75154b7c..986b3d90a 100644 --- a/exercises/190110304/1001S02E02_hello_python.py +++ b/exercises/190110304/1001S02E02_hello_python.py @@ -1 +1,11 @@ -print("hello world") \ No newline at end of file +i = 1 +while i < 10: + j = 1 + while j < i + 1: + if i%2 == 0: + break + print(j, '*', i, '=', i * j, sep='', end='\t') + j += 1 + + print() + i += 1 \ No newline at end of file