zoukankan      html  css  js  c++  java
  • Day5:Variable and recursive function

    """

    NAME = 'alex'          # global variable be capital

    def change_name():

         global name       # if no declaring the global name can also change the clglobal variable bu using the method of list:such as .appened()

         name = 'handsome' # local variable,be lower-case can have the same name,the difference between "c" program

         print('abcd',name)

         

    change_name()

    print(name)

    # ***********Function nest fuction*********

    NAME = 'alex'

    def zxver():

        name = 'zxver'

        print(name)

        def liu():

            name = 'liu'

            print(name)

            def linda():

                name = 'linda'

                print(name)

            print(name)

            linda()

        liu()

        print(name)

    zxver()

    # ********import easily be wrong

    AssertionErrorname = 'alex'

    def zxver():

        name = 'zxver'

        def liu():

            #1:global name

            nonlocal name 

            # 2:last stage's variable

            name = 'liu'

        liu()

        print(name)

        # ********1:print:zxver************

        # ********2:print:liu************

    print(name)

    zxver()

    print(name)

    # be careful: before the quote ,every function must be defined or will report wrong

    # ********recursion***************

    def calc(n):

        print(n)

        if (int(n/2) == 0):

           return(n)

        res = calc(int(n / 2))

        return(res)

    calc(10)

    """

    # *********defect:low efficiency*******

    import time

    person_list = ['alex','keyu','zxver','linda']

    def askway(person_list):

        print('-'*60)

        if len(person_list) == 0:

            return 'no one knows the way'

        person = person_list.pop(0)

        if person == 'zxver':

            return '%ssaid the way is turn left'%person

        print('do you know the way of the hall')

        print('%ssaid I do not know the way but i can ask %s'%(person,person_list))

        time.sleep(5)

        res = askway(person_list)

        print('%s the result is :%res'%(person,res))

        return res

        

    res = askway(person_list)

    print(res)

  • 相关阅读:
    oracle goldengate技术架构-简单试验(全)
    oracle goldengate安装
    Oracle HA 之 OGG部署流水
    Oracle HA 之 基于活动数据库复制配置oracle 11.2 dataguard
    Oracle HA 之 oracle 11.2 rac库配置active dataguard
    sosi-statistics
    xplan-打印执行顺序
    统计信息脚本
    Oracle管理监控之段空间利用监控-oracle性能优化
    监控7天内过期用户脚本
  • 原文地址:https://www.cnblogs.com/zxver/p/11974214.html
Copyright © 2011-2022 走看看