Skip to content

Commit

Permalink
黄哥所写python文章
Browse files Browse the repository at this point in the history
  • Loading branch information
likepython committed May 10, 2016
1 parent 64bb147 commit 3ec5114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions python/learn_python_follow_brother_huang_5.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,15 @@ if 或 if-else 语句中可以是任意语句,当然也可以是if或if-else
![](ch5_8.png)


# 判断结构实例:
# 判断结构实例:
1、判断是不是闰年
代表年的数字(如2016)能被4整除但不能被100整除,或能被400整除,那么这个年份为闰年。
整除的意思是能除尽,没有余数,python中用% 运算符, 2016 % 4 结果为 0
将闰年的定义,翻译为python语言中的逻辑表达式,变量year代表年份
year % 4 == 0 and year % 100 != 0 or year % 400 == 0
前面说过,关系运算符优先逻辑运算符,逻辑运算符and优先or,所以可以写成上面的表达式。
为了清晰,可以写成(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)

代表年的数字(如2016)能被4整除但不能被100整除,或能被400整除,那么这个年份为闰年。
整除的意思是能除尽,没有余数,python中用% 运算符, 2016 % 4 结果为 0。
将闰年的定义,翻译为python语言中的逻辑表达式,变量year代表年份。
year % 4 == 0 and year % 100 != 0 or year % 400 == 0
前面说过,关系运算符优先逻辑运算符,逻辑运算符and优先or,所以可以写成上面的表达式。
为了清晰,可以写成(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
![](ch5_9.png)


Expand Down
2 changes: 1 addition & 1 deletion python/learn_python_follow_brother_huang_6.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 跟黄哥学习python第五章
# 跟黄哥学习python第六章

# 循环结构

Expand Down

0 comments on commit 3ec5114

Please sign in to comment.