Python programming: From introductory to practical reading notes (i)

Source: Internet
Author: User

tuples:python values that cannot be modified are called immutable, and immutable lists are called tuples.

Such as:

dimensions= (200,50) print (Dimensions[0]) print (dimensions[1])

list: consists of a series of elements arranged in a particular order.

bicycles=[' Trek ', ' Cannondale ', ' Redline ']print (bicycles)

function: a code block with a name that is used to accomplish specific work.

def greet_user (username):    print ("Hello," + username.title () + "!")

  Pass arguments : positional arguments and keyword arguments

    positional arguments: The order of the arguments based on the argument.

    keyword Argument : is the name----value pair that is passed to the function. You associate the name and value directly in the argument.

class : Method _init_ () is a special method that Python will run automatically whenever an instance of the class is created.

Class Dog ():    def _init_ (self, Name, age):        self.name = name         Self.age = Age        def sit (self):        print ( Self.name.title () + "is now sitting.")    def roll_over (self):                print (Self.name.tilte () + "rolled over!")

  

Python programming: From introductory to practical reading notes (i)

Related Article

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.