习题21 函数可以返回某些东西
1 | def add(a, b): |
习题22 到现在为止你都学到了什么
1 | #回顾之前遇到的每一个词和每一个符号 |
习题23 字符串、字节串和字符编码
1 | import sys |
习题24 更多的练习
1 | print("Let's practice everything. ") |
习题25 更多更多的练习
1 | print("Let's practice everything. ") |
习题26 恭喜你,现在j可以考试了!
1 | print("How old are you?", end=' ') |
习题27 记住逻辑关系
1 | #and:与(既...又 全true才true |
习题28 布尔表达式练习
1 | print(3 != 4 and not ("testing" != "test" or "Python" == "Python")) |
习题29 if语句
1 | #if下一行4个空格缩进 |
习题30 else和if
#if elif else后面都有:
people = 30
cars = 40
trucks = 15
if cars > people:
print("We should take the cars. ")
elif cars < people:
print("We should not take the cars. ")
else:
print("We can't decide. ")
if trucks > cars:
print(" That's too many trucks. ")
elif trucks < cars: #if不满足看elif满不满足,而不是else(先elif再else 并列就按先后顺序来
print("Maybe we coule take the trucks. ")
else:
print("We still can't decide. ")
if people > trucks:
print("Alright , let's just take the trucks. ")
else:
print("Fine, let's stay home then. ")