欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-22 10:54:51
#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 tod... ......
#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