《Python编程:从入门到实践》第二章 变量和简单数据类型 习题答案

#2.1
print("Hello world!");
#2.2
message="Hello,Python!";
print(message);
#2.3
name="tian jiale";
print(name+",would you like to learn some Python today?");

#2.4
 #小写
print(name.lower()+",would you like to learn some Python today?");
 #大写
print(name.upper()+",would you like to learn some Python today?");
 #首字母大写
print(name.title()+",would you like to learn some Python today?");

#2.5
name="Myself";
message='"Study makes me happy,study is resoure of my happiness!"';
print(name+" once said,"+message);
#2.6
famous_person="Myself";
print(famous_person+" once said,"+message);
#2.7
name="\tMyself\n";
print(name);
print(name.lstrip()+" once said,"+message);
print(name.rstrip()+" once said,"+message);
print(name.strip()+" once said,"+message);

#2.8
print(5+3);
print(8-0);
print(2*4);
print(int(16/2));

#2.9
"""
这是一个注释
而且是多行注释
这个程序的目的就是为了演示注释
"""
print("这个程序的目的就是为了演示注释!");
#2.10
import this

 

你可能感兴趣的:(《Python编程:从入门到实践》第二章 变量和简单数据类型 习题答案)