Lesson one

来源:互联网 发布:电信4g网络也是cdma吗 编辑:程序博客网 时间:2024/04/29 04:49

Test1:Output the following contents with powershell.

1 print "Hello World!"2 print "Hello Again"3 print "I like typing this."4 print "This is fun."5 print 'Yay! Printing.'6 print "I'd much rather you 'not'."7 print 'I "said" do not touch this.'

firstly,我们要把上面这段代码通过文本编辑器(我用的是gedit,当然Windows自带的记事本也行)保存成.py的格式。

secondly,我们打开powershell,利用cd的命令打开你所保存的.py文件的文件夹,只有这样才能利用python来跑这段script。

finally,我们在光标处输入python (文件名).py再回车即可运行以上python脚步了。

Running result:

PS C:\Users\Admin\desktop> python ex1.py
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.

 

Other topic:

  1. 让你的script再多打印一行。
  2. 让你的script只打印一行。
  3. 在一行的起始位置放一个 ‘#’ (octothorpe) 符号。它的作用是什么?自己研究一下。

 

Let's solve the problems!

1:可以在当前的.py文件中修改源代码在代码末尾加入一行print “             ”,这样running的result就会变成多打印了一行(总觉得不应该这么傻瓜样的操作,看以后深入学习了再来修改这里吧)

2:只用一个print

3:这个我们可以自己加的试试running一下。结果出来我们很容易知道#号的功能是注释,在哪一行前面加上#,这一行的内容将不会被打印出来

 

至此,我们的习题一就结束了。


0 0
原创粉丝点击