File "<ipython-input-2-39a620940f47>", line 2
print "Hello Python 2.7 world!"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello Python 2.7 world!")?
练习
#1.个性化消息 #将用户的姓名存到一个变量汇总,并向该用户显示一条消息。显示的消息应非常简单,如:“Hello Eric, would you like to learn some Python today?”
name ="yegeli"
message ="Hello Eric, would you like to learn some Python today?"print(name +": "+ message )
yegeli: Hello Eric, would you like to learn some Python today?
#2.调整名子的大小写#将一个人名存储到一个变量中,再以小写、大写和首字母大写的方式显示这个人名
name ="yegeli"print(name.title())print(name.upper())print(name.lower())
Yegeli
YEGELI
yegeli
#3.名言 #找一句名言,将这个名人的姓名和他的名言打印出来。输出要求包括引号print('Albert Einstein Once said,"A person who never made a mistake never tried anything new."')#此时用单引号注意语法错误
Albert Einstein Once said,"A person who never made a mistake never tried anything new."
#4.名言2#重复名言,但将名人的姓名存到变量famous_person中,再创建要显示的消息,并将其存储到变量message中,然后打印这条消息
famous_person ="Albert Einstein"
message ="A person who never made a mistake never tried anything new."print(message)
A person who never made a mistake never tried anything new.