Description (class)
Select from exercise 9-1 to 9-15
Code (class)
9-3
1 | # 9-3 用户 :创建一个名为User 的类,其中包含属性first_name 和last_name , |
result:1
2
3
4
5
6Kate Snow
Hello Kate Snow!
Jone Ossaki
Hello Jone Ossaki!
Lin Li
Hello Lin Li!
9-5
1 | class User(): |
result:1
23
0
9-7
1 | # 9-7 管理员 :管理员是一种特殊的用户。编写一个名为Admin 的类,让它继承你为完成练习9-3或练习9-5而编写的User 类。 |
result:1
2
3can add post
can delete post
can ban user
9-11
1 | # 9-11 导入Admin 类 :以为完成练习9-8而做的工作为基础,将User 、Privileges 和Admin 类存储在一个模块中, |
nine
is the module define User and Admin
result:1
2
3
4
can add post
can delete post
can ban user
Description (file)
Select from exercise 10-1 to 10-16
Code (files)
10-1
1 | # 10-1 Python学习笔记 :在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的Python知识, |
result:1
2
3
4
5
6
7
8
9
10
11
12
13In Python you can code.
In Python you can create a game.
In Python you can use loop.
In Python you can code.
In Python you can create a game.
In Python you can use loop.
In Python you can code.
In Python you can create a game.
In Python you can use loop.
10-4
1 | # 10-4 访客名单 :编写一个while 循环,提示用户输入其名字。用户输入其名字后,在屏幕上打印一句问候语, |
result:1
2
3
4
5
6
7
8
9
10Input your name(q to quit): wang
Hello wang !
Input your name(q to quit): hey
Hello hey !
Input your name(q to quit): june
Hello june !
Input your name(q to quit): q
wang
hey
june
10-6 10-7
1 | # 10-6 加法运算 :提示用户提供数值输入时,常出现的一个问题是,用户提供的是文本而不是数字。在这种情况下, |
result:1
2
3
4
5
6
7
8Input 2 num, q to quit:a
b
Hey, error input, try again...
Input 2 num, q to quit:2
3
5
Input 2 num, q to quit:q
f