码迷,mamicode.com
首页 > 编程语言 > 详细

There are eight key elements of python

时间:2016-06-20 19:04:13      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:different   following   sometimes   elements   methods   

1. data type

2. variant

        grammer: objectReference = value

    ‘=‘  means bind a variant with object in memory.

     variant name is case sensitive in pyhon.

3. combination data type

    major types are meta and list

    meta is fixed.

    list is changable.

    #x.append(xxx)  == list.append(x,‘xxx‘)

    There are two call methods in python. as following.

    functionName(arguments)

    objectName.methodName(arguments)

4. logical operator

    sometimes "is" will give you a different result. in fact. its compared with memory object.

    0<=a<=10 equal a>=0 and a<=10

    "in" is better used in dict

5. control

    a.
    if boolean_expression1:

        suite1

    elif boolean_expression2:

    ....

    else:

        else_suite

    b.

    while boolean_expression:

        suite

    c.

    for variable in iterable:

        suite

6. mathmatic

    list must use iterable object.

    e.g. seeds+=5 # will get error

            seeds+=[5] #correct

7. IO

    try:

        ...

    except ValueError as err:

        print(err)

        continue

    except EOFError:

        break

8. function

    def functionName(argument1,a2,a3...):

            suite

There are eight key elements of python

标签:different   following   sometimes   elements   methods   

原文地址:http://luluuy.blog.51cto.com/279347/1791041

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!