# This program says hello and asks for my name.
print('Hello world!')
print('What is your name') # ask for their name
myName = input()
print('It is good to meet you,' + myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?') # ask for their age
myAge = input()
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
练习方法
1.写出原程序的功能,和每行的注释;
2.把注释复制粘贴到另外一个notepad++里,
3.根据注释写出自己的程序。
4.对比自己的程序和原来的程序,发现自己不足。
易错点
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
这行程序里的str(int(myAge)+1)
容易写错。
来源
chagelog
2020年3月12日