习题 1:第一个程序

将下面的内容写到一个文件中,取名为 ex1.py 。注意这个命名方式,Python 文件最好以 .py 结尾。

print("Hello World!")
print("Hello Again")
print("I like typing this.")
print("This is fun.")
print('Yay! Printing.')
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')

应看到的结果

 

 (注意:最后显示SyntaxEror(语法错误),告诉你究竟是什么样的错误。通常这些出错消息都非常难懂,不过可以尝试复制到搜索引擎里试一下)

巩固练习

  1.  让你的脚本再多打印一行。
    代码:

    结果: 
  2. 让你的脚本只打印其中一行。
  3. 在一行的起始位置放一个 “#” 字符。它的作用是什么,自己研究一下。
    2和3一起。
    代码:

     结果:

警告  #(octothorpe)有很多的英文名字,如pound(英镑符)、 hash(电话的#键)、mesh(网) 等

原文地址:https://www.cnblogs.com/llr211/p/11367910.html