<a href="http://www.reibang.com/p/54870e9541fc">總目錄</a>
課程頁面:https://www.udacity.com/course/intro-to-computer-science--cs101
授課教師:Dave Evans https://www.cs.virginia.edu/~evans/
如下內(nèi)容包含課程筆記和自己的擴展折騰
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)