1. Custom FunctionsThe custom function format is as follows:def (Parameter list): # !/usr/bin/python # define functions, print numbers def PRINTNUM5 (): # The range function, which generates the list collection, has 3 entry parameters:
One. How is python managed in memory?Python introduces a mechanism: reference counting.Python internally uses reference counting to keep track of objects in memory, and Python internally records how many references the object has, that is, the
These two days to learn some of the Python application tutorials, see this writing:
return series.apply (lambda x: (x-min_val)/scale)-1.0)
What is a lambda? Never seen, so search online, basically say Lambda is an anonymous function, to solve
Lambda is just an expression, and the function body is much simpler than def. The body of a lambda is an expression, not a block of code. Only a finite amount of logic can be encapsulated in a lambda expression. A lambda expression acts as a
function IntroductionIf you need a block of code multiple times when developing a program, but in order to improve the efficiency of writing and the reuse of code, it is necessary to organize code blocks with separate functions into a small module,
interface Default MethodThe default method of the interface is added after the Java8 version, not only the abstract method, but also the interface can contain several instance methods, define the instance method within the interface (but note that
Python3--function
Functions are well-organized, reusable pieces of code that are used to implement a single, or associated function.
Functions can improve the modularity of the application, and the reuse of the code. You already know
Operator.itemgetter functionThe Itemgetter function provided by the operator module is used to get the data of which dimensions of the object, with some ordinal numbers (that is, the number of the data that needs to be fetched in the object), as
The syntax for a lambda function contains only one statement, as follows: Lambda arg1,arg2,..... argn:expression (mainly see the following example)code example:#-*-coding:utf-8-*-# __author__ = "www.iplaypy.com" # ordinary Python function def Func (
The sort in the Python3 has been made very clear in sorting. For a practical example, sort the following list by creation time:
pages = [{' title ': ' Ten Years ' Learning Program Design ', ' time ': ' 2012-02-14 ', ' name ': ' 21-days '},{' title '
Task:Review 5 sessions (December 2)1.8 Recursively list files in a directory1.9 Anonymous functions2.0-2.4 built-in functionsNotes:Considerations for recursionMust have the last default resultif n = = 0Recursive parameters must converge to the
First, the function1. Function definition: function is a programming method of logical structure and processFunction Composition:1 function definition methods in Python:2 defTest (x):3 "The function Definitions"4X+=15 returnx6 def: Defines a
Operator.itemgetter functionThe Itemgetter function provided by the operator module is used to get the data of which dimensions of the object, with some ordinal numbers (that is, the number of the data that needs to be fetched in the object), as
Although I have encountered this problem in Python, it is easier to explain it in Ruby. In Ruby, there are many ways to traverse an array, and the two most commonly used are for and each:
Copy Code code as follows:
arr = [' A ', ' B ',
Sort (*, Key=none, Reverse=none)
Key denotes the sort keyword, and the reserve indicates whether it is in reverse order.
The Python3 sort is a stable order.
1. Simple numeric sorting
A = [5,3,2,4,1]
print (a)
a.sort ()
print (a)
2. Simple
Three ways to import a function
From math import sqrt #import the SQRT function is e.g. sqrt from math import * #import all functions from M Ath module e.g sqrt import math #import math Module,and use the function via math.* e.g. MATH.SQRT (25 )
Five exercises for lambda expressions
Grammar:
The lambda function, which is an anonymous function , creates the syntax:
Lambda parameters:express
Parameters: Optional, if provided, is usually a comma-delimited form of variable expressions, that is,
Functions are well-organized, reusable pieces of code that are used to implement a single, or associated function. Functions can improve the modularity of the application, and the reuse of the code, the function that you create is called the
A function is an organized, reusable code used to perform a single, related action block. Functions provide a better module for the height of application and code reuse.
As we know, Python has many built-in functions such as print (), but it can
Introduction
Functional programming (functional programming) concept originated in Lisp, founded by John McCarthy in 1958, the idea of automatic garbage collection was first proposed, and this concept is now being used for reference by
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.