<a href="http://www.jianshu.com/p/54870e9541fc">总目录</a>
课程页面:https://www.udacity.com/course/intro-to-computer-science--cs101
授课教师:Dave Evans https://www.cs.virginia.edu/~evans/
如下内容包含课程笔记和自己的扩展折腾
assert
按照Udacity的思路,需要用assert
。
通过油管上这个五分多钟视频,快速了解了下assert
怎么用。
# source: https://www.youtube.com/watch?v=BccybInHe8I
def power(x,y):
# Assume that x and y are both non-neg numbers.
assert x > 0, "x must be a positive number not %g" % x
assert y > 0, "y must be a pos number not {0}".format(y)
return x**y
print power(1, -3)