今天尝试使用了Eclipse+PyDev的Python编程环境,感觉还不错。今天Python大大给的作业如下:

下面是我完成的截图:

发散练习:

今天的作业主要是熟悉相关判断语句,如if、elif、else、pass。
由于 python 并不支持 switch 语句,所以多个条件判断,只能用 elif 来实现,如果判断需要多个条件需同时判断时,可以使用 or (或),表示两个条件有一个成立时判断条件成功;使用 and (与)时,表示只有两个条件同时成立的情况下,判断条件才成功。
以下附上相关知识:
Python条件语句:http://www.runoob.com/python/python-if-statement.html
网友评论