From 17c8d23ca864b7cb1e9269e7110e55dd4db0df0f Mon Sep 17 00:00:00 2001 From: hanhan Date: Sun, 3 Jun 2018 16:38:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "exercise/3\345\217\230\351\207\217/variable.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "exercise/3\345\217\230\351\207\217/variable.py" diff --git "a/exercise/3\345\217\230\351\207\217/variable.py" "b/exercise/3\345\217\230\351\207\217/variable.py" new file mode 100644 index 0000000..469712d --- /dev/null +++ "b/exercise/3\345\217\230\351\207\217/variable.py" @@ -0,0 +1,14 @@ + +# # 练习一 变量的定义和使用 +# +# 1. 定义两个变量分别为美元和汇率 +# 2. 通过搜索引擎找到美元兑人民币汇率 +# 3. 使用Python计算100美元兑换的人民币数量并用print( )进行输出 + +dollar = 100.00 +exchange_rate = 6.42 +rmb = dollar * exchange_rate + + + +print("%f 美元兑换的人民币数量= %f " %(dollar,rmb)) \ No newline at end of file From dfa922a3341ddd1dda81d85978c79c71f2b67a19 Mon Sep 17 00:00:00 2001 From: hanhan Date: Sun, 3 Jun 2018 17:02:52 +0800 Subject: [PATCH 2/5] init --- "exercise/4\345\272\217\345\210\227/sequence.py" | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 "exercise/4\345\272\217\345\210\227/sequence.py" diff --git "a/exercise/4\345\272\217\345\210\227/sequence.py" "b/exercise/4\345\272\217\345\210\227/sequence.py" new file mode 100644 index 0000000..c73a40d --- /dev/null +++ "b/exercise/4\345\272\217\345\210\227/sequence.py" @@ -0,0 +1,5 @@ +# 练习一 字符串 + +1. 定义一个字符串Hello Python 并使用print( )输出 +2. 定义第二个字符串Let‘s go并使用print( )输出 +3. 定义第三个字符串"The Zen of Python" -- by Tim Peters 并使用print( )输出 \ No newline at end of file From 96be2f9ad4d1b5cc153804eb6fd41a3a0f4d255f Mon Sep 17 00:00:00 2001 From: hanhan Date: Sun, 3 Jun 2018 17:07:46 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=BB=83=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4\345\272\217\345\210\227/sequence.py" | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git "a/exercise/4\345\272\217\345\210\227/sequence.py" "b/exercise/4\345\272\217\345\210\227/sequence.py" index c73a40d..792a0d1 100644 --- "a/exercise/4\345\272\217\345\210\227/sequence.py" +++ "b/exercise/4\345\272\217\345\210\227/sequence.py" @@ -1,5 +1,22 @@ -# 练习一 字符串 +# # 练习一 字符串 +# +# 1. 定义一个字符串Hello Python 并使用print( )输出 + +str1 = 'Hello Python!' + +print(str1) + +# 2. 定义第二个字符串Let‘s go并使用print( )输出 + +str2 = "Let's go" + +print(str2) + +# 3. 定义第三个字符串"The Zen of Python" -- by Tim Peters 并使用print( )输出 + +str3 = " \"The Zen of Python\" -- by Tim Peters" + +print(str3) + + -1. 定义一个字符串Hello Python 并使用print( )输出 -2. 定义第二个字符串Let‘s go并使用print( )输出 -3. 定义第三个字符串"The Zen of Python" -- by Tim Peters 并使用print( )输出 \ No newline at end of file From dd0beee9fee0e8274d3107cf3e6cbacd73454a95 Mon Sep 17 00:00:00 2001 From: hanhan Date: Sun, 3 Jun 2018 18:50:15 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4\345\272\217\345\210\227/sequence.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git "a/exercise/4\345\272\217\345\210\227/sequence.py" "b/exercise/4\345\272\217\345\210\227/sequence.py" index 792a0d1..87cbca9 100644 --- "a/exercise/4\345\272\217\345\210\227/sequence.py" +++ "b/exercise/4\345\272\217\345\210\227/sequence.py" @@ -20,3 +20,30 @@ +# # 练习二 字符串基本操作 +# +# 1. 定义两个字符串分别为 xyz 、abc + +str_a = 'xyz' +str_b = 'abc' + +# 2. 对两个字符串进行连接 + +print(str_a + str_b) + +# 3. 取出xyz字符串的第二个和第三个元素 + +print('xyz字符串的第二个元素是 %s ' % str_a[1]) +print('xyz字符串的第三个元素是 %s ' % str_a[2:]) + +# 4. 对abc输出10次 + +for i in range(10) : + print('输出 %s 第 %i 次' %(str_b,i+1)) + +# 5. 判断a字符(串)在 xyz 和 abc 两个字符串中是否存在,并进行输出 + +if 'a' in str_a : + print('a字符(串)在 xyz ') +elif 'a' in str_b : + print('a字符(串)在 abc ') \ No newline at end of file From 6c62f6925237ebdbb29543a99b80a7a24507dea8 Mon Sep 17 00:00:00 2001 From: hanhan Date: Mon, 4 Jun 2018 23:39:56 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4\345\272\217\345\210\227/sequence.py" | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git "a/exercise/4\345\272\217\345\210\227/sequence.py" "b/exercise/4\345\272\217\345\210\227/sequence.py" index 87cbca9..e4c1778 100644 --- "a/exercise/4\345\272\217\345\210\227/sequence.py" +++ "b/exercise/4\345\272\217\345\210\227/sequence.py" @@ -46,4 +46,33 @@ if 'a' in str_a : print('a字符(串)在 xyz ') elif 'a' in str_b : - print('a字符(串)在 abc ') \ No newline at end of file + print('a字符(串)在 abc ') + +# # 练习三 列表的基本操作 +# +# 1.定义一个含有5个数字的列表 + +a_list = [1,2,3,4,5] + +print(a_list) + +# +# 2.为列表增加一个元素 +# 100 + +a_list.append(100) + +print(a_list) + +# +# 3.使用remove() 删除一个元素后观察列表的变化 + +a_list.remove(1) + +print(a_list) + +# +# 4.使用切片操作分别取出列表的前三个元素,取出列表的最后一个元素 + +print('列表的前三个元素',a_list[:3]) +print('列表的最后一个元素',a_list[-1]) \ No newline at end of file