From 6a1bb3037d35b9d14fa21d9f27f8d444188b208d Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 29 Jul 2019 18:20:49 +0800 Subject: =?UTF-8?q?LectureNotesOnPython.rst:=20=E5=88=9D=E5=AD=A6=E8=80=85?= =?UTF-8?q?=E5=AE=B9=E6=98=93=E7=8A=AF=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LectureNotesOnPython.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'LectureNotesOnPython.rst') diff --git a/LectureNotesOnPython.rst b/LectureNotesOnPython.rst index 174bff0..61dd22a 100644 --- a/LectureNotesOnPython.rst +++ b/LectureNotesOnPython.rst @@ -427,6 +427,18 @@ a是变量名。 'a'是值。 a = 'a' 这个语句要从右边向左边读, 这很正常。 编程要达到一定的代码量, 才能渐渐感觉清晰。 你的第一个目标是100行代码, 实现这个目标后下一个目标是500行代码, 当你的代码量超过1000行时, 很多问题会渐渐清晰。 出错也很正常, 认识到错误的原因, 把错误改正了, 就等于进步了。 +**练习** 以下是初学者写的代码, 反应了初学者容易出错的地方。 指出每个语句的错误所在。 + + +- x.upper # 函数忘记加括号, 应该是 x.upper() + +- t = my*999 #字符串忘记加单引号, 应该是 t = 'my' * 999 + +- t=my*999 # 等号前后没有空格 (编程风格差), 应该是 t = 'my' * 999 + + + + **练习** 把下面这段文字转成字符串并存在变量boris中。 Boris Johnson, Prime Minister of the United Kingdom. Alexander Boris de Pfeffel Johnson is a British politician serving as Prime Minister of the United Kingdom and Leader of the Conservative Party since July 2019. He has been the Member of Parliament for Uxbridge and South Ruislip since 2015 and was the MP for Henley from 2001 to 2008. He also served as Mayor of London from 2008 to 2016 and Foreign Secretary from 2016 to 2018. Johnson identifies as a one-nation conservative and has been associated with both economically and socially liberal policies. -- cgit v1.2.1