I. RecursionRecursion is the function itself calling itselfRecursive maximum usable depth in Python is 997Recursion can be used to traverse various tree structures#to view the contents of a file within a path using a recursive methodImportOsFilePath=
Python Language Programming Basics Exercise 2.5ImportTurtledefDrawtriangle (Num,len,flag):#flag is used to adjust the direction of the triangle.Flag*=-1Len/=2if(num==1): if(flag==1): Turtle.left (60) turtle.fd (len) turtle.right (120)
When Python2 and Python3 are installed on Windows at the same time, their corresponding Pip is called Pip.exe, so it is not possible to install the package directly using the PIP Install command. Instead, you use the initiator Py.exe to specify the
Use of adorners:Use when you do not want to modify the function's invocation, but want to add content to the functionWhy use adorners: Software entities should be extensible and non-modifiable. In other words, the extension is open, and the
Loop statement: Repeat, to do the same or type of thing under a certain condition,Three elements of a looping statement:Cyclic condition + cyclic body + cyclic condition changeWhile condition: Loop body Cyclic condition Change...While
Object orientedclass : A collection of objects used to describe the same properties and methodsmethod : A function defined in a class class variables: Class variables are defined in a class and outside the body of a function, class variables are not
The following information is referenced in: http://www.xinxingjiaocheng.com/online/item/7/891. Give the module an aliasIf the name of a module is long and long, like this comput_the_value_of_the_variable, you import the module like this:Import
One, iteratorWe already know that for there are several types of data that can be directly acting on a loop:A class is a collection of data types, such as,,, list tuple , and dict set str so on;One is generator to include the generator and yield the
TYPE.__NEW__ (): Returns the class. You can think of a class as an instance created by Metaclass.__new__ () in the normal class: Returns an instance of the class.__NEW__ (): Returns an instance of the class. The Python interpreter executes
1. How the For loop works:For loop:D={' A ': 1, ' B ': 2, ' C ': 3}for i in D: print (i)Principle: The For loop is actually the d.__iter__ of the D in the back ()# Todo Loop first time: obj=d.__iter__ () i=obj.__next__ () print (i) # Todo loop
First, the Python2 and Python3 are handled differently in rangeTake range (100) as an example, Python2 will immediately create 0-100 in memory, and Python3 will not be created immediately, only when used to create the desiredRange is used to help us
Exercise: The user enters a name, age, work, hobby, and then prints the following format------------info of Egon-----------name : egonage : 22Sex: malejob : Teacher-------------End-----------------Name = input (' Please enter your name >>:
Tag:png style strong mes calculation yield get generator gen yield It 's kind of like return, but he's going to continue from the last point at the next execution, the function with yield is called generator(generator)
Slice (int,int)Slices, you can add readability to the name of the slice.Example:Sorted (Iterable, key)ordering, which supports incoming parameters, such as by Itemgetter Incoming parameters ( Itemgetter can pass in multiple keys). Example:Using
Filter (callable, list/tuple)Receives a function and a sequence to complete element filtering.Example:Fnmatch (str,str) match patterns using casing-sensitive rules for the underlying operating system . Example:Fnmatchcase(str,str) Use your pattern
The in method is used in Python31 #determine if a key exists in the dictionary2arr = {"int":"integer","float":"floating point","Str":"string","List":"List","tuple":"Meta-group","Dict":"Dictionary","Set":"Collection"}3 #using the In method4 if "int"
Escape character: It is inconvenient to output from the keyboard, or the original character has a special meaning of some characters,Here are a few common escape characters\ ', \ ', ' \ ', \ ' "", \ \ are all meant to represent the original
: Network Disk Download"How to Think-a computer scientist" is a introduction to programming using Python, one of the best languages for B Eginners. This was a free book--Can download it from thinkpython.com. But if you would a contribution to this
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service