python编程从入门到实践第二章习题答案

请对照相关书籍进行阅读

2.1-2.2
message = "Hello Python!"
print( message )

message = "Hello Zhichao"
print ( message )
 2.3
message = "ada"
print( "Hello " + message + ",would you like to learn some Python today?" )

2.4
name = "ada"

print( name.lower() )
print( name.upper() )
print( name.title() )
2.5
print('Albert Einstein once said, "A person who never made a mistake never tried anything new"')
2.6
famous_person = "Albert Einstein"
print(famous_person + ' once said, "A person who never made a mistake never tried anything new"')
2.7
name = " \tAlbert Einstein\n "

print( name )
print( name.lstrip() )
print( name.rstrip() )
print( name.strip() )
2.8
print( 3+5 )
print( 9-1 )
print( 2*4 )
print( int(16/2) )

print( 2**3 )
print( 17//2 )
2.9-2.10
num = 957  #WE
message = "my favorite number is " + str(num)

print(message) #2018/3/7

2.11
import this

你可能感兴趣的:(python习题,python学习)