学习派森的第八天>*8
今天做完一个大题。
发现一个网站题跟codecademy一样。也许账号pro的试用期过了之后我可以用这个自己作题?
https://danielmoralesp.gitbooks.io/inteligencia-artificial/chapter1/152-learn-python-functions.html
这个好像也行。
题并不是很难,只是多层嵌套。
依然还是阅读理解很麻烦,而且赋值的名称有很多,到最后快要搞混。
做了测试,七个选择题错俩 = =。
在print一句话的时候,加入一个返回值是数字的话需要str()

a function does not always have to have an explicit return statement. If the function doesn’t need to provide any results to the calling point, then the return is not needed. However, there will be a value of None which is implicitly returned by Python.
函数不一定都要返回(return)一个值,如无必要勿增实体。不过如果返回值没有必要的时候,派森默认返回一个"None"。
写了一个验证密码的程序:
用了break,没有新东西,重要的还是逻辑,捋顺了就行。
原来之前times和cont没有什么区别只是赋值的一个载体而已。。。

cont=3 password="okin520" while cont: passwd=input("请输入密码:") if passwd == password: print("密码正确,进入程序......") break elif "*" in passwd: print("密码中不能含有'*'号,您还有",cont,"次机会。",end=" ") continue else: print("密码输入错误!您还有",cont-1,"次机会!",end=" ") cont-=1
另外重新写了一遍小游戏
又跟之前不一样了:

我都用了elif。
想改回去改不回去了不知道为啥。。。
我累了,反正对了就行。