<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                通過對四則運算的學習,已經初步接觸了Python中內容,如果看官是零基礎的學習者,可能有點迷惑了。難道在IDE里面敲幾個命令,然后看到結果,就算編程了?這也不是那些能夠自動運行的程序呀? 的確。到目前位置,還不能算編程,只能算會用一些指令(或者叫做命令)來做點簡單的工作。并且看官所在的那個IDE界面,也是輸入指令用的。 列位稍安勿躁,下面我們就學習如何編寫一個真正的程序。工具還是那個IDLE,但是,請大家謹記,對于一個真正的程序來講,用什么工具是無所謂的,只要能夠把指令寫進去,比如用記事本也可以。 我去倒杯茶,列位先認真讀一讀下面一段,關于程序的概念,內容來自維基百科: * 先閱讀一段英文的:[computer program and source code](http://en.wikipedia.org/wiki/Computer_program),看不懂不要緊,可以跳過去,直接看下一條。 > A computer program, or just a program, is a sequence of instructions, written to perform a specified task with a computer.[1] A computer requires programs to function, typically executing the program's instructions in a central processor.[2] The program has an executable form that the computer can use directly to execute the instructions. The same program in its human-readable source code form, from which executable programs are derived (e.g., compiled), enables a programmer to study and develop its algorithms. A collection of computer programs and related data is referred to as the software. > > Computer source code is typically written by computer programmers.[3] Source code is written in a programming language that usually follows one of two main paradigms: imperative or declarative programming. Source code may be converted into an executable file (sometimes called an executable program or a binary) by a compiler and later executed by a central processing unit. Alternatively, computer programs may be executed with the aid of an interpreter, or may be embedded directly into hardware. > > Computer programs may be ranked along functional lines: system software and application software. Two or more computer programs may run simultaneously on one computer from the perspective of the user, this process being known as multitasking. * [計算機程序](http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A8%8B%E5%BA%8F) > 計算機程序(Computer Program)是指一組指示計算機或其他具有信息處理能力裝置每一步動作的指令,通常用某種程序設計語言編寫,運行于某種目標體系結構上。打個比方,一個程序就像一個用漢語(程序設計語言)寫下的紅燒肉菜譜(程序),用于指導懂漢語和烹飪手法的人(體系結構)來做這個菜。 通常,計算機程序要經過編譯和鏈接而成為一種人們不易看清而計算機可解讀的格式,然后運行。未經編譯就可運行的程序,通常稱之為腳本程序(script)。 碧螺春,是我最喜歡的了。有人要送禮給我,請別忘記了。難道我期望列位看官會送嗎?哈哈哈 廢話少說,開始說程序。程序,簡而言之,就是指令的集合。但是,有的程序需要編譯,有的不需要。python編寫的程序就不需要,因此她也被稱之為腳本程序。特別提醒列位,不要認為編譯的就好,不編譯的就不好;也不要認為編譯的就“高端”,不編譯的就屬于“低端”。有一些做了很多年程序的程序員或者其它什么人,可能會有這樣的想法,這是毫無根據的。 不爭論。用得妙就是好。 ## 用IDLE的編程環境 操作:File->New window [![](https://box.kancloud.cn/2015-07-06_559a588b3fdb6.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10501.png) 這樣,就出現了一個新的操作界面,在這個界面里面,看不到用于輸入指令的提示符:>>>,這個界面有點像記事本。說對了,本質上就是一個記事本,只能輸入文本,不能直接在里面貼圖片。 [![](https://box.kancloud.cn/2015-07-06_559a5890aa497.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10502.png) ## 寫兩個大字:Hello,World Hello,World.是面向世界的標志,所以,寫任何程序,第一句一定要寫這個,因為程序員是面向世界的,絕對不畏縮在某個局域網內,所以,所以看官要會科學上網,才能真正與世界Hello。 直接上代碼,就這么一行即可。 ~~~ print "Hello,World" ~~~ 如下圖的樣式 [![](https://box.kancloud.cn/2015-07-06_559a58967c2f1.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10503.png) 前面說過了,程序就是指令的集合,現在,這個程序里面,就一條指令。一條指令也可以成為集合。 注意觀察,菜單上有一個RUN,點擊這個菜單,在下拉的里面選擇Run Moudle [![](https://box.kancloud.cn/2015-07-06_559a589d4e6d5.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10504.png) 會彈出對話框,要求把這個文件保存,這就比較簡單了,保存到一個位置,看官一定要記住這個位置,并且取個文件名,文件名是以.py為擴展名的。 都做好之后,點擊確定按鈕,就會發現在另外一個帶有>>>的界面中,就自動出來了Hello,World兩個大字。 成功了嗎?成功了也別興奮,因為還沒有到慶祝的時候。 在這種情況系,我們依然是在IDLE的環境中實現了剛才那段程序的自動執行,如果脫離這個環境呢? 下面就關閉IDLE,打開shell(如果看官在使用蘋果的 Mac OS 操作系統或者某種linux發行版的操作系統,比如我使用的是ubuntu),或者打開cmd(windows操作系統的用戶,特別提醒用windows的用戶,使用windows不是你的錯,錯就錯在你只會使用鼠標點來點去,而不想也不會使用命令,更不想也不會使用linux的命令,還夢想成為優秀程序員。),通過命令的方式,進入到你保存剛才的文件目錄。 下圖是我保存那個文件的地址,我把那個文件命名為105.py,并保存在一個文件夾中。 [![](https://box.kancloud.cn/2015-07-06_559a58b2998c5.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10505.png) 然后在這個shell里面,輸入:python 105.py 上面這句話的含義就是告訴計算機,給我運行一個python語言編寫的程序,那個程序文件的名稱是105.py 我的計算機我做主。于是它給我乖乖地執行了這條命令。如下圖: [![](https://box.kancloud.cn/2015-07-06_559a58b6b9c9d.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10506.png) 還在沉默?可以歡呼了,德國隊7:1勝巴西對,列看官中,不管是德國隊還是巴西隊的粉絲,都可以歡呼,因為你在程序員道路上邁出了偉大的第二步。順便預測一下,本屆世界杯最終冠軍應該是:中國隊。(還有這么扯的嗎?) ## 解一道題目 請計算:19+2*4-8/2 代碼如下: ~~~ #coding:utf-8 """ 請計算:19+2*4-8/2 """ a = 19+2*4-8/2 print a ~~~ 提醒初學者,別復制這段代碼,而是要一個字一個字的敲進去。然后保存(我保存的文件名是:105-1.py)。 在shell或者cmd中,執行:python (文件名.py) 執行結果如下圖: [![](https://box.kancloud.cn/2015-07-06_559a58bac6791.png)](https://github.com/qiwsir/ITArticles/blob/master/Pictures/10507.png) 上面代碼中,第一行,不能少,本文件是能夠輸入漢字的,否則漢字無法輸入。 好像還是比較簡單。 別著急。復雜的在后面呢。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看