python基础练习题1

# 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)容易写错。

来源

Python编程快速上手 (豆瓣)英文版

chagelog

2020年3月12日

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容