快乐又不要钱,为什么不呢?
【注】本文中所有的代码本人全部测试通过后才写在下面。考虑到夹杂结果图片太乱,所以没加。大家复制代码拿去运行即可。
前面章节的答案后续会补上。
【注】所有包含中文的代码都必须把编码设置成UTF-8才能正常运行。我用的是Geany,设置方法为:文档——设置文件编码——Unicode-——UTF-8
持续更新……
第二章
print("Hello my new life,\nhllo ,the technology world.\nplese be gentle to me.")
2-2
message="Hello my new life,\nhllo ,the technology world.\nplese be gentle to me."
print(message)
2-3
name = 'Eric'
print('Hello '+name+', would you like to learn some pyghon today?')
2-4
name = 'eric'
print(name.title())
print(name.upper())
print(name.lower())
name = 'albert einstein'
saying="A person who never made a mistake never tried anything new."
print(name.title()+"once said"+": "+'\n\t"'+saying+'"')
name = ' albert einstein '
saying="A person who never made a mistake never tried anything new."
print(name.title())
print(name.title().lstrip().rstrip()+"once said"+": "+'\n\t"'+saying+'"')
print(name.strip())
print(80/10)
print(2*4)
print(10-2)
number=4
print("my favorite number is "+str(number))
第三章
names=['王辰','王杰','许博文','肖嘉良','田家铭','徐汉章']
for name in names:
print(name)
names=['王辰','王杰','许博文','肖嘉良','田家铭','徐汉章']
for name in names:
print('Hello '+name+" it's good to see you !")
names=['car','bicycle','shared bikes','motorcycle','bus']
for name in names:
print('To be the truth ,my favorite vehicle is '+name+'.')
names=['泽东','和珅','胡雪岩','华罗庚','王羲之']
for name in names:
print('Dear '+name+' ,i respectfully invite you to join me for dinner.')
names=['泽东','和珅','胡雪岩','华罗庚','王羲之']
for name in names:
print('Dear '+name+' ,i respectfully invite you to join me for dinner.')
print('\n\nSorry the '+names[-2]+' has no time these days ,please call someone else.')
names[-2]='张三丰'
print(names)
for name in names:
print('Dear '+name+' ,i respectfully invite you to join me for dinner.')
names=['泽东','和珅','胡雪岩','华罗庚','王羲之']
for name in names:
print('Dear '+name+' ,i respectfully invite you to join me for dinner.')
print('\n\nSorry the '+names[-2]+' has no time these days ,please call someone else.')
names[-2]='张三丰'
print(names)
for name in names:
print('Dear '+name+' ,i respectfully invite you to join me for dinner.'