Python Learning record 3

Source: Internet
Author: User

: Appears at the end of a function definition statement

such as: if expression:

Elif expression:

else: etc

Defining functions Using Def

def Hanshu (x)

Description

Return (the value returned when the function is called)

The usage of default parameters is not very clear:

def foo (debug=true):
' Detemine if in debug mode with default argument '
If debug:
print ' in debug mode '
print ' Done '

The output is ' done ' when the value is False

If the true value only wants to output the first sentence, I think I should add continue to jump out of the loop,

But in reality, I've added continue to the error.

Class calls internal properties
First, define a class, and the properties and methods inside the class, such as:

If the base class must be defined as object, define ABC error

Class Hello (object):

a=0.5

The function is defined earlier

def add (x)

Return (X+X)

function call class with parameter

Add (HELLO.A)

Output is 1

Python Learning record 3

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.