Python编程入门(第3版)3.5  源代码注释_Python编程入门(第3版)3.5  源代码注释试读-查字典图书网
查字典图书网
当前位置: 查字典 > 图书网 > 编程 > Python编程入门(第3版) > 3.5  源代码注释

Python编程入门(第3版)——3.5  源代码注释

前面使用了源代码注释来指出文件名, 但注释还可用于在程序中添加各种说明,如文档、提示、解释或警告。Python 忽略所有注释,它们仅供你和其他可能阅读源代码的程序员阅读。 下面的示例程序演示了注释的其他一些用途: # coins_short.py # This program asks the user how many # coins of various types they have, # and then prints the total amount # of money in pennies. # get the number of nickels, dimes, # and quarters from the user n = int(input('Nickels? ')) d = int(input('Dimes? ')) q = int(input('Quarters? ')) # calculate the total amount of money total = 5 * n + 10 * d + 25 * q # print the results print() # prints a blank line print(str(total) + ' cents')

展开全文


推荐文章

猜你喜欢

附近的人在看

推荐阅读

拓展阅读

《Python编程入门(第3版)》其他试读目录

• 1.1  Python 语言
• 1.2  Python 适合用于做什么
• 1.3  程序员如何工作
• 1.4  安装Python
• 3.1  使用IDLE 的编辑器
• 3.2  编译源代码
• 3.3  从键盘读取字符串
• 3.4  在屏幕上打印字符串
• 3.5  源代码注释 [当前]
• 3.6  程序的组织
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  •