Description (if)
Select from exercise 5-1 to 5-13
Code (if)
5-3
1 | # 5-3 外星人颜色#1 :假设在游戏中刚射杀了一个外星人,请创建一个名为alien_color 的变量, |
result:1
Get 5 points!
5-6
1 | # 5-6 人生的不同阶段 :设置变量age 的值,再编写一个if-elif-else 结构,根据age 的值判断处于人生的哪个阶段。 |
result:1
2
3
4
5
6a baby
learning how to walk
a child
a teenage
an adult
the old
5-8
1 | # 5-8 以特殊方式跟管理员打招呼 :创建一个至少包含5个用户名的列表,且其中一个用户名为'admin' 。 |
result:1
2
3
4
5Hello Eric, thank you for logging in again!
Hello Kris, thank you for logging in again!
Hello Smith, thank you for logging in again!
Hello admin, would you like to see a status report?
Hello Harry, thank you for logging in again!
5-9
1 | # 5-9 处理没有用户的情形 :在为完成练习5-8编写的程序中,添加一条if 语句,检查用户名列表是否为空。 |
result:1
We need to find some users!
5-11
1 | # 5-11 序数 :序数表示位置,如1st和2nd。大多数序数都以th结尾,只有1、2和3例外。 |
result:1
2
3
4
5
6
7
8
91st
2nd
3rd
4th
5th
6th
7th
8th
9th
Description (dictionary)
Select from exercise 6-1 to 5-13
Code (dictionary)
6-3
1 | # 6-3 词汇表 :Python字典可用于模拟现实生活中的字典,但为避免混淆,我们将后者称为词汇表。 |
result:1
2python: easy to get star.
if: if what happen then do something.
6-4
1 | # 6-4 词汇表2 :既然你知道了如何遍历字典,现在请整理你为完成练习6-3而编写的代码,将其中的一系列print |
result:1
2
3
4
5
6
7
8
9
10if: if what happen then do something.
while: loop.
or: in bool, A happens or B happens are both fine.
var: record some number, string, dictionary etc.
python: easy to get star.
import: as include in c.
for: another loop.
and: only if A and B both true.
class: var define by coder.
print: to print string and begin a new line.
6-8
1 | #6-8 宠物 :创建多个字典,对于每个字典,都使用一个宠物的名称来给它命名;在每个字典中, |
result:1
2
3
4Kingkong is a dog, it is Tony's friend!
Kitty is a cat, it is Jessica's friend!
Big Bird is a snake, it is Jason's friend!
Son is a kangaroo, it is Micheal's friend!