震惊了!每30秒学会一个Python小技巧


向大家推荐一个将碎片化时间利用到极致的github项目《30-seconds-of-python》

作者实现了List、Math、Object、Utility方面74个小函数,每个学习时间仅需30秒,而且每个实例都给出了思路、实现代码和example,以阶乘为例:

Factorial(Calculates the factorial of a number)

Use recursion. If num is less than or equal to 1, return 1. Otherwise, return the product of num and the factorial of num - 1. Throws an exception if num is a negative or a floating point number.

def factorial(num):
  if not ((num >= 0) and (num % 1 == 0)):
    raise Exception(
      f"Number( {num} ) can't be floating point or negative ")
  return 1 if num == 0 else num * factorial(num - 1)
Examples
factorial(6) # 720

作者还建了一个网站,方便大家查找

https://github.com/30-seconds/30-seconds-of-python

此外,30秒学Python只是作者庞大计划其中一支,还有CSS/PHP/React等方向值得大家去挖掘更多精彩!

30 seconds of Code

30 seconds of CSS

30 seconds of Interviews

30 seconds of Knowledge

30 seconds of React

30 seconds of PHP

项目地址

https://python.30secondsofcode.org

END

添加微信,我们在微信群接着聊

推荐阅读

收藏 | 数据分析师最常用的10个机器学习算法!

一张让你代码能力突飞猛进的速查表

信息熵、条件熵、联合熵、互信息、相对熵、交叉熵

【干货收藏】人工智能必看的45篇论文

如何轻松阅读 GitHub 上的项目源码 ?

手把手教你Python实现30 个主流机器学习算法

一张图看清各种机器学习算法涉及的数学知识,哪里薄弱补哪里,so easy!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值