今天看啥  ›  专栏  ›  Python入门与进阶

Python程序员的进化

Python入门与进阶  · 公众号  ·  · 2018-08-31 13:45
来源:https://coolshell.cn/articles/2082.html以前本站发布过一篇《程序员的进化》,以一种幽默的代码展现方式调侃了程序。下面这篇是关于Python程序员的。以阶乘为例,很有意思新手程序员def factorial(x):    if x == 0:        return 1    else:        return x * factorial(x - 1)print factorial(6)第一年刚学完Pascal的新手def factorial(x):    result = 1    i = 2    while i        result = result * i        i = i + 1    return resultprint factorial(6)第一年刚学完C语言的新手def fact(x): #{    result = i = 1;    while (i #{        result *= i;        i += 1;    #}    return result;#}print(fact(6))第一年刚学完SICP的新手@tailcalldef fact(x, acc=1):    if (x > 1): return (fact((x - 1), (acc * x)))    else:       return accprint(fact(6))第一年刚学完Py ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照