• Lesson one of python


    Test1:Use the powershell to output the contents

    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.'

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

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

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

    Running result:

    PS C:UsersAdmindesktop> 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. 让你的脚本再多打印一行。
    2. 让你的脚本只打印一行。
    3. 在一行的起始位置放一个 ‘#’ (octothorpe) 符号。它的作用是什么?自己研究一下。

    Let's solve the problems!

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

    2:只用一个print

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

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

  • 相关阅读:
    (转)关于IBM小机P520的面板使用
    (转)mysql的sql_mode合理设置
    (转)Mysql技术内幕InnoDB存储引擎-事务&备份&性能调优
    杨辉三角
    异或的陷阱(转)
    通过数组看栈堆
    数组的一些知识点和插入选择冒泡排序
    运算符
    Java的变量相关
    有符号的数据表示法(原、反、补)
  • 原文地址:https://www.cnblogs.com/learnC/p/5546137.html
Copyright © 2020-2023  润新知