美文网首页
Python_18_Udacity_Evans_Intro to

Python_18_Udacity_Evans_Intro to

作者: 张一闻 | 来源:发表于2016-05-24 07:26 被阅读27次

    <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)
    

    相关文章

      网友评论

          本文标题:Python_18_Udacity_Evans_Intro to

          本文链接:https://www.haomeiwen.com/subject/jxczrttx.html