同一个问题

不同层次的Python程序员

编出的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 <= x:

resultresult = result * i

ii = i + 1

return result print factorial(6)

一年编程经验(学C的)def fact(x): #{

result = i = 1;

while (i <= x): #{

result *= i;

i += 1;

#}

return result; #} print(fact(6))

一年编程经验(读过SICP)@tailcall def fact(x, acc=1):

if (x > 1):

return (fact((x - 1), (acc * x)))

else:

return acc

print(fact(6))

一年编程经验(Python)def Factorial(x):

res = 1

for i in xrange(2, x + 1):

res *= i

return res print Factorial(6)

懒惰的Python程序员def fact(x):

return x > 1 and x * fact(x - 1) or 1 print fact(6)

更懒的Python程序员f = lambda x: x and x * f(x - 1) or 1 //匿名函数

print f(6)

Python专家fact = lambda x: reduce(int.__mul__, xrange(2, x + 1), 1) print fact(6)

Python黑客import sys @tailcall def fact(x, acc=1):

if x: return fact(x.__sub__(1), acc.__mul__(x))

return acc

sys.stdout.write(str(fact(6)) + ' ')

一般人压根看不懂

专家级程序员from c_math import fact print fact(6)

大英帝国程序员from c_maths import fact print fact(6) def factorial(x):

#-------------------------------------------------

#--- Code snippet from The Math Vault ---

#--- Calculate factorial (C) Arthur Smith 1999 ---

#-------------------------------------------------

result = str(1)

i = 1 #Thanks Adam

while i <= x:

#result = result * i #It's faster to use *=

#result = str(result * result + i)

#result = int(result *= i) #??????

result = str(int(result) * i)

#result = int(str(result) * i)

i = i + 1

return result print factorial(6)

Unix 程序员import os def fact(x):

os.system('factorial ' + str(x))

fact(6)

Windows 程序员NULL = None def CalculateAndPrintFactorialEx(dwNumber,

hOutputDevice,

lpLparam,

lpWparam,

lpsscSecurity,

*dwReserved):

if lpsscSecurity != NULL:

return NULL #Not implemented

dwResult = dwCounter = 1

while dwCounter <= dwNumber:

dwResult *= dwCounter

dwCounter += 1

hOutputDevice.write(str(dwResult))

hOutputDevice.write(' ')

return 1 import sys

CalculateAndPrintFactorialEx(6, sys.stdout, NULL, NULL, NULL,

NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) 可能自己都晕菜了...

企业级程序员def new(cls, *args, **kwargs):

return cls(*args, **kwargs) class Number(object):

pass class IntegralNumber(int, Number):

def toInt(self):

return new (int, self) class InternalBase(object):

def __init__(self, base):

self.base = base.toInt()

def getBase(self):

return new (IntegralNumber, self.base) class MathematicsSystem(object):

def __init__(self, ibase):

Abstract

@classmethod

def getInstance(cls, ibase):

try:

cls.__instance

except AttributeError:

cls.__instance = new (cls, ibase)

return cls.__instance class StandardMathematicsSystem(MathematicsSystem):

def __init__(self, ibase):

if ibase.getBase() != new (IntegralNumber, 2):

raise NotImplementedError

self.base = ibase.getBase()

def calculateFactorial(self, target):

result = new (IntegralNumber, 1)

i = new (IntegralNumber, 2)

while i <= target:

result = result * i

i = i + new (IntegralNumber, 1)

return result print StandardMathematicsSystem.getInstance(new (InternalBase,

new (IntegralNumber, 2))).calculateFactorial(new (IntegralNumber, 6))

面向对象,但就此题来说,又长又臭。

python程序员工资待遇-看看你是哪种级别的Python程序员(已跪)相关推荐

  1. 又涨了!2021 年 5 月程序员工资统计新鲜出炉,网友:还是Java程序员牛逼~

    新鲜出炉!2021年5月全国招收程序员429056人.2021年5月全国程序员平均工资14926元,工资中位数13000元,其中96%的人的工资介于1750元到75000元. 部分城市程序员工资收入情 ...

  2. python应届生工资待遇_讲真,应届生一般工资多少啊?

    今日,一则关于应届生薪酬的话题冲上知乎热榜图片来源:知乎截图 相信薪酬是很多即将毕业的同学特别关注的话题,那么我们今天就来看下部分高校2019届毕业生的薪酬吧! 看了上述数据,你的薪资水平拖后腿了么? ...

  3. python数据分析师工资待遇_预测python数据分析师的工资

    前两篇博客分别对拉勾中关于 python 数据分析有关的信息进行获取( 一.对薪资进行转换 在这之前先导入模块并读入文件,不仅有训练数据文件,还有一组自拟的测试数据文件. importpandas a ...

  4. 专科python应届生工资多少-应届毕业生自述面试15K月薪的Python后端开发经历,希望对你有用...

    原标题:应届毕业生自述面试15K月薪的Python后端开发经历,希望对你有用 前言 马上就要到十二月,2018年也即将过去,众所周知每年的三四月份都是招聘高峰期,俗称:"金三银四" ...

  5. python遍历数组冒泡排序法_十种排序七种搜索算法的Python实现——气泡排序,十大,七大,查找,python,冒泡排序,bubblesort...

    一.十大排序算法 数据准备 使用random库随机生成无序数组 import random def random_list(start, end, number): temp = [] i = 0 w ...

  6. 武汉Java程序员工资是否还会增长?工资为什么那么高?

    武汉Java开就业薪资多少?一直是很多学习的人关心的问题,毕竟,大家花费时间和精力学习Java都是希望能收获一份满意的高薪工作.那么,学习武汉Java开发后薪资一般有多少呢?下面,给大家分析一下. 武 ...

  7. python的工资待遇-python数据分析师待遇有多少?工资待遇如何?

    随着大数据时代的到来,企业对数据价值的重视,python数据分析师的市场越来越大,毫无疑问python数据分析师已成为"当今最具发展潜力的职业",吸引了无数像小编这样的热血青年,在 ...

  8. 上海python工资一般多少-python数据分析师待遇有多少?工资待遇如何?

    随着大数据时代的到来,企业对数据价值的重视,python数据分析师的市场越来越大,毫无疑问python数据分析师已成为"当今最具发展潜力的职业",吸引了无数像小编这样的热血青年,在 ...

  9. 程序员工资一般多少钱一个月?【推荐】

    其他行业没这么麻烦,一个职位总是有很多人能胜任的,选择多了,公司就有条件把工资降低.但在程序员招聘方面,谈工资的权利在程序员手里,因为对方没有选择.程序员本来就那么稀有,非常适合要求的程序员更是稀有之 ...

  10. python爬虫工资怎样_【python爬虫工程师工资|python爬虫工程师待遇怎么样】-看准网...

    定制个人薪酬报告python爬虫工程师工资水平(元/月-税前) ¥9188 职位平均工资 你认为这个数据靠谱吗? 靠谱 0太低 0太高 0 python爬虫工程师工资详情 该职位在0-5k薪资范围占1 ...

最新文章

  1. 求单链表的最大值与原地逆转_江西师范大学硕士学位研究生入学考试数据结构试题(2003年)一.doc...
  2. WebRTC:应用中最大难点在于根据业务需求的适当折中
  3. Delphi 变体类型(Variant)的介绍(流与变体类型的相互转换、变体类型常用的函数)...
  4. 合法整数集(51Nod-1315)
  5. rpc 服务器不可用_什么是远程过程调用RPC
  6. myeclipse里html添加背景颜色,myeclipse怎么设置主题-设置myeclipse主题背景颜色的教程 - 河东软件园...
  7. python 线程池的研究及实现
  8. BP算法和RNN_RNN/LSTM BPTT详细推导以及梯度消失问题分析
  9. self._handle = _dlopen(self._name, mode) OSError: [WinError 126] 找不到指定的模块
  10. BZOJ 3224: Tyvj 1728 普通平衡树(替罪羊树)
  11. Matplotlib绘制半圆形
  12. 快播将关闭QVOD服务器 宅男,你心碎了吗?
  13. P3755 [CQOI2017]老C的任务
  14. 电脑游戏计算机哪年发明的,电子计算机发明于哪一年
  15. 自定义桌面开始按钮(winxp、7、8、8.1、10)
  16. java poi打印excel_POI打印Excel报表
  17. 工控机的日常维护方法及步骤
  18. python 获取百度地图上北京地铁的数据,然后excel导出
  19. Web前端JQuery入门实战案例
  20. 计算机专业笔记本硬盘256G,老笔记本重获新生 东芝256G固态硬盘体验

热门文章

  1. 腾讯云轻量型服务器与云服务器的区别
  2. 裁员,缩招,冻结HC,程序员如何应对?
  3. YouTube批量下载开源代码汇总
  4. SLAM 学习笔记 本质矩阵E、基础矩阵F、单应矩阵H的推导
  5. 微步在线【威胁情报】
  6. 有量纲和无量纲是什么意思_为什么无线通信需要同步?
  7. 【51单片机快速入门指南】5.2:SPI读取 12位ADC XPT2046 芯片
  8. 基于HyperLPR的车牌识别(十三)
  9. 利用xlsl.full.js导入excel表格
  10. macOS 下的 homebrew