随笔分类 -  Python Learning

摘要:A method is similar to a function – it takes arguments and returns a value – but the syntax is different. For example, the method upper takes a string... 阅读全文
posted @ 2014-06-29 15:22 平静缓和用胸音说爱 阅读(284) 评论(0) 推荐(0)
摘要:Find: In a sense, find is the opposite of the [] operator. Instead of taking an index and extracting the corresponding character, it takes a... 阅读全文
posted @ 2014-06-23 22:06 平静缓和用胸音说爱 阅读(245) 评论(0) 推荐(0)
摘要:It is tempting to use the [] operator on the left side of an assignment, with the intention of changing a character in a string. The ‘object... 阅读全文
posted @ 2014-06-23 10:51 平静缓和用胸音说爱 阅读(275) 评论(0) 推荐(0)
摘要:String slicesA segment of a string is called a slice. Selecting a slice is similar selecting a character: The operator [n:m] returns the par... 阅读全文
posted @ 2014-06-20 17:33 平静缓和用胸音说爱 阅读(217) 评论(0) 推荐(0)
摘要:A lot of computations involve processing a string one character at a time. Often they start at the beginning, select each character in turn, do someth... 阅读全文
posted @ 2014-06-20 16:21 平静缓和用胸音说爱 阅读(169) 评论(0) 推荐(0)
摘要:len is a build-in function that returns the numbers of characters in a string: Since we started counting at zero, the last index should be 5... 阅读全文
posted @ 2014-06-18 19:18 平静缓和用胸音说爱 阅读(255) 评论(0) 推荐(0)
摘要:A string is a sequence of characters. You can access the characters one at a time with the bracket operator. The second statement selects ch... 阅读全文
posted @ 2014-06-18 19:02 平静缓和用胸音说爱 阅读(148) 评论(0) 推荐(0)
摘要:Loops are often used in programs that compute numerical results by starting with an approximate answer and iteratively improving it.For example, one w... 阅读全文
posted @ 2014-06-18 15:24 平静缓和用胸音说爱 阅读(556) 评论(0) 推荐(0)
摘要:Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that computers do well ... 阅读全文
posted @ 2014-06-10 14:44 平静缓和用胸音说爱 阅读(329) 评论(0) 推荐(0)
摘要:Keyboard inputPython provides a build-in function called raw_input (in version 2.x) that gets input from the keyboard. In Python 3.x we use input(). W... 阅读全文
posted @ 2014-05-01 15:28 平静缓和用胸音说爱 阅读(342) 评论(0) 推荐(0)
摘要:RecursionIt is legal for one function to call another; it is also legal for a function to call itself. It may not be obvious why what is a good thing,... 阅读全文
posted @ 2014-05-01 15:07 平静缓和用胸音说爱 阅读(264) 评论(0) 推荐(0)
摘要:1. Modulus operator (%)The modulus operator works on integers and yields the remainder when the first operand is divided by the second. In Python, the... 阅读全文
posted @ 2014-04-28 18:10 平静缓和用胸音说爱 阅读(523) 评论(0) 推荐(0)
摘要:1. Write a function called square that takes a parameter named t, which is a turtle. It should use the turtle to draw a square.from TurtleWorld import... 阅读全文
posted @ 2014-04-24 16:13 平静缓和用胸音说爱 阅读(255) 评论(0) 推荐(0)
摘要:TurtleWorld provides a set of functions for drawing lines by steering turtles around the screen. You can download Swampy from allendowney.com/swampy.U... 阅读全文
posted @ 2014-04-24 14:05 平静缓和用胸音说爱 阅读(530) 评论(0) 推荐(0)
摘要:It may not be clear why it is worth the trouble to divide a program into functions. There are a lot of reasons; here are few:Creating a new function gives you an opportunity to name a group of statements, which makes your program easier to read and debug.Functions can make a program smaller by elimi 阅读全文
posted @ 2014-04-11 19:17 平静缓和用胸音说爱 阅读(192) 评论(0) 推荐(0)
摘要:Python is an example of high-level language. As you might infer from the name “high-level language”, there are also low-level languages, sometimes referred to as “machine languages” or “assembly languages”. Loosely speaking, computers can only execute programs written in low-level languages. So prog 阅读全文
posted @ 2014-04-08 17:41 平静缓和用胸音说爱 阅读(423) 评论(0) 推荐(0)