Lecture4:decomposition and abstraction through functions;introduction to recursion function decomposition abstraction and recursionFunctions function
Block up into modules decomposition into modules
Suppress detail ignoring details
6.1 laziness is a virtue
Currently, the programs we write are very small. If you want to write a large program, you need to reuse the code. This problem can be solved by creating a function.
6.2 abstraction and Structure
Abstraction can save a lot
#面向对象: polymorphism, encapsulation, inheritance#1 polymorphism: It means that even if you don't know what type of object the variable refers to, you can manipulate it, and it will behave differently depending on his type.#多态和方法From randomImport
6.4.5 reversal process
We have already discussed how to collect parameters as tuples and dictionaries. But in fact, if you use * and *, you can perform the opposite operation.
>>> def add(x,y): return x+y>>> params=(1,2)>>> add(*params)3
You can
Fibonacci sequence Fibonacci Sequence, also known as the Golden section of the series, refers to such a series: 0, 1, 1, 2, 3, 5, 8, 13, 、...... Mathematically, the Fibonacci sequence is defined as a recursive method: F (0) =0,f (1) =1,f (n) =f (n-1)
I. Object-oriented and process-oriented1.1 Process-oriented featuresThe advantage is that it greatly reduces the complexity of the writing process, and only needs to stack the code along the steps to be performed.The disadvantage is: a set of
First, what is object-oriented programmingOO programming (Object Oriented programming), or OOP, is a programming idea. OOP takes objects as the basic unit of a program, and an object contains functions for data and manipulating data.Process-oriented
# "Functional Programming" """"function is a kind of encapsulation supported by Python, we can decompose complex tasks into simple tasks by splitting large pieces of code into functions through a layer of function calls, which can be called
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.