【题解】Quiz 1 (An Introduction to Interactive Programming in Python)

吐槽:目的是记录python中随机数用法。以及这个课确实比python for everyone系列麻烦一些,而且有些东西确实查了才知道。

题目:

1. The function calls random.randint(0,10) andrandom.randrange(0,10) generate random numbers in different ranges. What number can be generated by one of these functions, but not the other?

(Refer to the CodeSkulptor documentation.)

By the way, we (and most Python programmers) always prefer to use random.randrange() since it handles numerical ranges in a way that is more consistent with the rest of Python.

我想说的:

1,这是个填空题,而且答案是一个数字,所以我查了一下边界情况(https://zhidao.baidu.com/question/1367834445354854619.html),即random.randint(1,100)随机数中使包括1和100的,而random.randrange(1,100)则不包括100。

2,查看源码真是个神奇的方法=。=

 

你可能感兴趣的:(题解,Python)