Python Basic Learning (3rd day)

Source: Internet
Author: User

6th class Cycle

1. For element in sequence:

Statement

New Python function range (): Creates a new sequence, all integers, starting with 0, the next element is 1 larger than the previous element, up to the upper limit of the series (excluding the upper limit). Ps:range () Changes in usage in 3.2

For a in  range (5):2     print a output:4 15 26 37 4   
View Code

2. While condition:

Statement

3, continue, break

7th Lesson function

A = 1def Change_integer (a):    a = a + 1    return aprint Change_integer (a) print a#=== (the content followed by "#" in Python is commented, not executed) b = [1 , 2,3]def change_list (b):    b[0] = b[0] + 1    return bprint change_list (b) Print B

Take this code as an example, value passing and pointer passing

The first: The parameter is passed an integer variable A, the function operates on it, but does not change the value of A; because the base data type is passed as a parameter to the function, the function copies a variable in memory and does not change the original value of the variable (value pass)

The second one: passing a sequence as a parameter to a function, the value of the sequence changes after the function operation, because the number biographies past is the pointer, the pointer points to the position of the sequence in memory, the function is directly in memory and affects the original variable (pointer passing)

8th, 9 class object oriented

1, through the object can modify the properties of the class, but this is very dangerous , because the object of the class and the object of the subclass are sharing this property, once modified, will affect all objects.

Python Basic Learning (3rd day)

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.