diff --git a/fundamental/index.html b/fundamental/index.html index 14d6a35..7becb4d 100755 --- a/fundamental/index.html +++ b/fundamental/index.html @@ -670,7 +670,7 @@

Fundamental

-

這裡將會教你基礎的Python與C++的基礎與法。

+

這裡將會教你基礎的Python與C++的基礎語法。

diff --git a/fundamental/python/index.html b/fundamental/python/index.html index 423f4af..378eac2 100755 --- a/fundamental/python/index.html +++ b/fundamental/python/index.html @@ -672,6 +672,8 @@

Python

+

嗨,我是 @cheung4843,是Python系列的作者。在一開始基礎語法的部分會教得特別詳細,文章中的專有名詞將會以黃色與綠色標示,請你稍微注意一下,若不懂也沒關係,我會在後面章節再次提到。

+

在每一個小節的後面都會有筆記區以及問題區,尤其是問題區,請你好好思考。而在每一篇文章最後都會放上一些練習題,請嘗試完成他們!

diff --git a/fundamental/python/say_hello/index.html b/fundamental/python/say_hello/index.html index 02c7336..e630cc7 100755 --- a/fundamental/python/say_hello/index.html +++ b/fundamental/python/say_hello/index.html @@ -555,6 +555,39 @@ + + + + +
  • + + + Practice + + +
  • @@ -722,6 +755,39 @@ + + + + +
  • + + + Practice + + +
  • @@ -823,6 +889,7 @@

    First Program

    @EditTime : 2024-01-25 19:55

    Variable and Input

    +

    Variable

    接下來,來點好玩的。

    1
     2
    @@ -842,7 +909,11 @@ 

    Variable and Input +

    Quote

    +

    在Python中,一切都是物件。

    +

    請觀看下面的動畫。

    @@ -851,20 +922,58 @@

    Variable and InputVØJ, Narvent - Memory Reboot (4K Music Video)

    -

    但是如果每次想要修改 x 裡面的東西,難道都要在程式碼中修改嗎?能不能我自己來輸入呢?

    -
    1
    -2
    -3
    -4
    -5
    x = input("Enter a number: ")
    -print(type(x))
    -y = input("Enter another number: ")
    -z = int(x) + int(y)
    -print("The sum is: ", z)
    +

    再來介紹幾種不同的變數類型。

    +

     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    +11
    +12
    +13
    +14
    a = 114514
    +print(type(a))
    +b = 1919810.0
    +print(type(b))
    +c = 10e3
    +print(type(c))
    +d = "cheung4843"
    +print(type(d))
    +e = True
    +print(type(e))
    +f = False
    +print(type(f))
    +h = None
    +print(type(h))
     
    -

    喔幹,怎麼一下子多出那麼多東西,別慌,我來解釋,但請你先回想在前一節中學過的東西,你可以發現 input, int, type 都是函式。而 input 括號中的字串會顯示在控制台中提示你要輸入什麼,type 則告訴你括號中的東西是什麼類別(Class),最後,int 則是把括號中的東西的類別轉換成整數。

    -

    那為什麼印出type(x) 得到 <class 'str'> 呢?代表 x 是一個字串,這是因為 input 總是將你輸入進來的東西當成字串,但我想要讓 z = x + y 這個數學式子成立,所以需要用 int 來將字串轉換成整數再進行運算。

    -

    那下面這個程式碼的輸出結果是什麼呢?

    +type 告訴你括號中的東西是什麼類別(Class)

    +

    bc 都是浮點數(Float),也就是小數點的數字,而 d 則是字串,ef 則是布林(Boolean),而 h 則是空值。

    +
    +

    Note

    +
      +
    1. type(x) 回傳 x 的類別。
    2. +
    3. int 整數。
    4. +
    5. float 浮點數。
    6. +
    7. str 字串。
    8. +
    9. bool 布林。
    10. +
    11. None 空值。
    12. +
    +
    +
    +

    Question

    +
      +
    1. print(type(3 + 4.0)) 會印出什麼?
    2. +
    3. print(type(3 + True)) 會印出什麼?
    4. +
    +
    +

    @EditTime : 2024-01-27 16:44

    +

    Input

    +

    但是如果每次想要修改 x 裡面的東西,難道都要在程式碼中修改嗎?能不能我自己來輸入呢?

    1
     2
     3
    @@ -872,33 +981,62 @@ 

    Variable and Input5

    x = input("Enter a number: ")
     print(type(x))
     y = input("Enter another number: ")
    -z = x + y
    +z = int(x) + int(y)
     print("The sum is: ", z)
     
    +

    喔幹,怎麼一下子多出那麼多東西,別慌,我來解釋,但請你先回想在前一節中學過的東西,你可以發現 input, int, 都是函式。而 input 括號中的字串會顯示在控制台中提示你要輸入什麼,int 則是把括號中的東西的類別轉換成整數。

    +

    那為什麼印出type(x) 得到 <class 'str'> 呢?代表 x 是一個字串,這是因為 input 總是將你輸入進來的東西當成字串,但我想要讓 z = x + y 這個數學式子成立,所以需要用 int 來將字串轉換成整數再進行運算。

    +

    那下面這個程式碼的輸出結果是什麼呢?

    +
    1
    +2
    +3
    +4
    +5
    x = input("Enter a number: ")
    +print(type(x))
    +y = input("Enter another number: ")
    +z = x + y
    +print("The sum is: ", z)
    +

    沒錯,字串的相加,就是相連。那你要不要試試看相減?

    +

    接下來我們來做個有趣的實驗,順便認識一下 f-string +

    1
    +2
    +3
    +4
    +5
    +6
    a = 3.5
    +b = int(a)
    +print(f'The value of b is {b}, and its type is {type(b)}')
    +c = float(b)
    +print(f'The value of c is {c}, and its type is {type(c)}')
    +print(b == c)
    +

    +

    f-string 是什麼東西呢?他是一種字串格式化(String Formatting)的方法,他會將括號內的東西轉換成字串,並將字串中的 {} 替換成括號內的東西。

    +

    而執行完程式碼後,你會發現 bc 的類別不同,但他們的值卻相同,這是因為 int()float() 都是將括號內的東西轉換成整數與浮點數,而 int() 會將浮點數的小數點捨去,而 float() 則會將整數轉換成浮點數。

    +

    那麼 b == c 是什麼意思呢?他是一個比較運算子(Comparison Operator),他會比較等號左右兩邊的東西是否相等,如果相等,則回傳 True,否則回傳 False

    那如果我今天想要一次輸入好幾個字串,每一個字串以空格來隔開呢? 但在這之前,我們先來看一個小程式 :

    -
    1
    -2
    -3
    a, b = "Hello World".split()
    -print(a)
    -print(b)
    +
    1
    +2
    +3
    a, b = "Hello World".split()
    +print(a)
    +print(b)
     

    我知道怪怪的,為什麼字串後面接了一個 .split() 呢?在這裡他很像是函式,但又不是函式,那他叫什麼呢?他被稱為 "Hello World" 這個字串的方法(Method),但未來你可能還會聽到類別方法(Class Method),以及靜態方法(Static Method) 等名詞,我怕你會搞混,所以你就先認逗點後面的是「方法」就好了。

    .split() 會把字串以括號內的東西來切割字串並回傳(那你想想括號內什麼都沒放,預設會是什麼?),而看看等號左邊,我用 a, b 去接著,這稱為開箱(Unpacking)

    那現在你應該能看懂下面的程式碼了,因為 input() 也會回傳一個字串,因此他也能夠使用 .split()

    -
    1
    -2
    -3
    a, b = input().split()
    -print(a)
    -print(b)
    +
    1
    +2
    +3
    a, b = input().split()
    +print(a)
    +print(b)
     

    Note

    1. input() 接受輸入,回傳一個字串。
    2. int(x)x 轉換成整數。
    3. -
    4. type(x) 回傳 x 的類別。
    5. +
    6. float(x)x 轉換成浮點數。
    7. str.split() 以括號內的東西來切割字串,並回傳。
    @@ -908,30 +1046,55 @@

    Variable and Inputprint(int(input()) + int(input())) 會印出什麼?
  • 124.spilt("1") 是合法的嗎?
  • +
  • bool(0)bool(1) 會回傳什麼?
  • 看以下的程式碼,為什麼它們的功能相同,ab 成功互換了呢?
  • -
    1
    -2
    -3
    -4
    a, b = 4, 5
    -print(a, b)
    -a, b = b, a
    -print(a, b)
    +
    1
    +2
    +3
    +4
    a, b = 4, 5
    +print(a, b)
    +a, b = b, a
    +print(a, b)
     
    -
    1
    -2
    -3
    -4
    -5
    -6
    a, b = 4, 5
    -print(a, b)
    -tmp = a
    -a = b
    -b = tmp
    -print(a, b)
    +
    1
    +2
    +3
    +4
    +5
    +6
    a, b = 4, 5
    +print(a, b)
    +tmp = a
    +a = b
    +b = tmp
    +print(a, b)
     

    @EditTime : 2024-01-25 22:17

    +

    Practice

    +

    在這篇文章中,你學到了:

    +
    +

    Summary

    +
      +
    1. 如何使用 print()input()
    2. +
    3. 知道變數的概念。
    4. +
    5. 知道 type(x)int(x), float(x) 的用途。
    6. +
    7. 知道 str.split() 的用途。
    8. +
    9. 知道如何使用 f-string
    10. +
    +
    +

    那現在你可以試試看以下的題目了。

    +
    +

    ZeroJudge - a001. 哈囉

    +
    +
    +Reference code +
    1
    +2
    word = input()
    +print(f'hello, {word}')
    +
    +
    +

    @EditTime : 2024-01-27 17:02

    diff --git a/index.html b/index.html index c19bc20..31c2de2 100755 --- a/index.html +++ b/index.html @@ -789,6 +789,7 @@

    Hello LMcps Book!Welcome to LMcps!

    黎明資訊社(LMcps)創立於2018年,指導者為李惠文老師。

    +

    本書的正確打開方式是暗色模式

    print("Hello LMcps Book!")
     print("Welcome to LMcps!")
    diff --git a/search/search_index.json b/search/search_index.json
    index 4cf4085..dd60a94 100755
    --- a/search/search_index.json
    +++ b/search/search_index.json
    @@ -1 +1 @@
    -{"config":{"lang":["en"],"separator":"[\\s\\u200b\\u3000\\-\u3001\u3002\uff0c\uff0e\uff1f\uff01\uff1b]+","pipeline":["stemmer"]},"docs":[{"location":"","title":"Hello LMcps Book!","text":""},{"location":"#welcome_to_lmcps","title":"Welcome to LMcps!","text":"

    \u9ece\u660e\u8cc7\u8a0a\u793e(LMcps)\u5275\u7acb\u65bc2018\u5e74\uff0c\u6307\u5c0e\u8005\u70ba\u674e\u60e0\u6587\u8001\u5e2b\u3002

    print(\"Hello LMcps Book!\")\nprint(\"Welcome to LMcps!\")\n
    "},{"location":"#why_does_it_start","title":"Why does it start?","text":"

    \u57282024/1/25\uff0c\u662f\u75ab\u60c5\u5f8c\uff0c\u7b2c\u4e00\u6b21\u6b77\u5c46\u793e\u54e1\u8fd4\u56de\u6bcd\u6821\u8207\u5b78\u5f1f\u59b9\u5011\u5206\u4eab\u7d93\u9a57\u7684\u65e5\u5b50\uff0c\u5728\u8207\u8001\u5e2b\u53ca\u5b78\u5f1f\u59b9\u5011\u4ea4\u6d41\u5f8c\uff0c\u767c\u73fe\u4e86\u76ee\u524d\u8cc7\u8a0a\u6559\u80b2\u7684\u7a98\u56f0\uff0c\u8af8\u5982\u7db2\u8def\u4e0a\u7684\u8cc7\u6e90\u96d6\u591a\uff0c\u4f46\u4e0d\u6613\u5165\u9580\uff0c\u65bc\u662f\u6c7a\u5b9a\u5beb\u4e00\u672c\u66f8\uff0c\u4ee5\u5927\u91cf\u7684\u5716\u7247\u53ca\u7c21\u55ae\u7684\u6587\u5b57\uff0c\u8b93\u5b78\u5f1f\u59b9\u5011\u80fd\u5920\u5feb\u901f\u5165\u9580\uff0c\u4e26\u4e14\u80fd\u5920\u5728\u77ed\u6642\u9593\u5167\uff0c\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\u8207\u81ea\u4fe1\u3002

    "},{"location":"#content","title":"Content","text":"

    \u9019\u672c\u66f8\u8457\u91cd\u65bc\u61c9\u7528\u9762\uff0c\u4e26\u4e14\u5be6\u4f5c\u70ba\u4e3b\uff0c\u4e5f\u4e26\u975e\u5e36\u4f60\u6253\u7af6\u7a0b\uff0c\u800c\u662f\u5e36\u4f60\u4e86\u89e3\u91cd\u8981\u7684\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5\u3002\u5be6\u4f5c\u8a9e\u8a00\u4ee5Python\u70ba\u4e3b\uff0c\u6703\u6709\u5c11\u6578C++\u7684\u5be6\u4f5c\u3002

    "},{"location":"#contributors","title":"Contributors","text":"

    Success

    1. \u7b2c\u4e8c\u4efb\u793e\u9577
    "},{"location":"license/","title":"License","text":"

    MIT License

    Copyright (c) 2023 Cheung4843

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    "},{"location":"fundamental/","title":"Fundamental","text":"

    \u9019\u88e1\u5c07\u6703\u6559\u4f60\u57fa\u790e\u7684Python\u8207C++\u7684\u57fa\u790e\u8207\u6cd5\u3002

    "},{"location":"fundamental/cpp/","title":"C++","text":""},{"location":"fundamental/python/","title":"Python","text":""},{"location":"fundamental/python/say_hello/","title":"Say Hello to Python!","text":""},{"location":"fundamental/python/say_hello/#first_program","title":"First Program","text":"

    \u55e8\uff0c\u9019\u662f\u4f60\u7b2c\u4e00\u500b Python \u7a0b\u5f0f\uff0c\u5728 Pycharm \u4e2d\u5efa\u7acb\u4e00\u500b main.py \u6a94\u6848\uff0c\u4e26\u5728\u6a94\u6848\u4e2d\u6253\u4e0a :

    # print(\"Hello Cat!\")\nprint(\"Hello World!\")\nprint('Hello Python!')\nprint(\"cheung4843\")\n

    \u6309\u4e0b\u57f7\u884c\u5f8c\uff0c\u4f60\u7684\u63a7\u5236\u53f0(Console)\u5c07\u6703\u5370\u51fa Hello World! \u63a5\u8457\u63db\u884c\uff0c\u518d\u5370\u51fa Hello Python!\uff0c\u63a5\u8457\u518d\u5370\u51fa\u6211 cheung4843\uff0c\u518d\u63db\u884c\u3002

    \u90a3 # print(\"Hello Cat!\") \u662f\u4ec0\u9ebc?\u4ee5\u4e95\u5b57\u865f\u70ba\u958b\u982d\u7684\uff0c\u88ab\u7a31\u70ba\u8a3b\u89e3\uff0c\u4ed6\u4e0d\u6703\u5728\u7a0b\u5f0f\u4e2d\u88ab\u57f7\u884c\uff0c\u800c\u4ed6\u7684\u4f5c\u7528\uff0c\u4f60\u4ee5\u5f8c\u4e00\u5b9a\u80fd\u9ad4\u6703\u3002

    \u4e0d\u66c9\u5f97\u4f60\u662f\u5426\u6709\u767c\u73fe \"Hello World!\" \u8207 'Hello Python!' \u7684\u5dee\u7570?\u7576\u7136\u9664\u4e86\u5b57\u6bcd\u4e0d\u4e00\u6a23\u4e4b\u5916\uff0c\u9084\u6709\u96d9\u5f15\u865f\u8207\u55ae\u5f15\u865f\u7684\u5dee\u5225\uff0c\u4f46\u4ed6\u5011\u90fd\u88ab\u7a31\u70ba\u5b57\u4e32(String)\uff0c\u5728 Python \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6210\u5c0d\u7684\u96d9\u5f15\u865f\u8207\u55ae\u5f15\u865f\u4f86\u8868\u9054\u4e00\u500b\u5b57\u4e32\uff0c\u4f46\u662f\u4e0d\u80fd\u6df7\u7528\uff0c\u4f8b\u5982 :

    print(\"I love cats')\n

    \u57f7\u884c\u5f8c\uff0c\u4f60\u6703\u767c\u73fe\u63a7\u5236\u53f0\u8ddf\u4f60\u5831\u544a\u4e86\u932f\u8aa4\uff0c\u9019\u662f\u8a9e\u6cd5\u932f\u8aa4\uff0c\u800c\u5f8c\u7e8c\u5beb\u7a0b\u5f0f\u7684\u904e\u7a0b\u4e2d\uff0c\u4f60\u5c07\u906d\u9047\u8a31\u591a\u8a9e\u610f\u932f\u8aa4\u3002

    \u90a3\u4f60\u77e5\u9053\u4ec0\u9ebc\u662f\u7a7a\u5b57\u4e32\u55ce?

    print('')\nprint(\"\")\nprint(\"Above are nothing, right?\")\n

    \u57f7\u884c\u5b8c\u5f8c\uff0c\u4f60\u5c31\u77e5\u9053\u7a7a\u5b57\u4e32\u662f\u4ec0\u9ebc\u4e86\u5427?

    \u63a5\u8457\u6211\u5011\u4f86\u8b1b\u8b1b print \u9019\u500b\u6771\u897f\uff0c\u6211\u5011\u5728 Python \u4e2d\u7a31\u4ed6\u70ba\u51fd\u5f0f(Function)\uff0c\u6211\u5011\u8981\u5982\u4f55\u4f7f\u7528\u5462?\u4e5f\u5c31\u662f\u5728\u51fd\u5f0f\u7684\u540d\u7a31\u5f8c\u52a0\u4e0a\u4e00\u500b\u62ec\u865f()\u3002\u800c print \u662f Python \u5167\u5efa\u7d66\u6211\u5011\u7684\u300c\u5de5\u5177\u300d\uff0c\u5c31\u662f\u8aaa\uff0c\u6211\u5011\u4e0d\u77e5\u9053\u4ed6\u662f\u600e\u9ebc\u88ab\u9020\u51fa\u4f86\u7684\uff0c\u6211\u5011\u73fe\u968e\u6bb5\u53ea\u8981\u77e5\u9053\u600e\u9ebc\u7528\u5c31\u597d\uff0c\u6216\u8a31\u4f60\u53ef\u80fd\u807d\u904e\u4e00\u500b\u8001\u6389\u7259\u7684\u6bd4\u55bb\uff0c\u7a31\u51fd\u5f0f\u5c31\u50cf\u662f\u4e00\u500b\u9ed1\u76d2\u5b50\u3002

    \u95dc\u65bc\u51fd\u5f0f(Function)\uff0c\u6211\u6703\u5728\u5f80\u5f8c\u7684\u7ae0\u7bc0\u8ddf\u4f60\u4ecb\u7d39\uff0c\u800c\u73fe\u5728\u4f60\u53ea\u8981\u77e5\u9053 print() \u6703\u5c07\u62ec\u865f\u5167\u7684\u6771\u897f\u5370\u51fa\u4f86\uff0c\u4e26\u63db\u884c\u3002

    \u90a3\u5982\u679c\u6211\u4e0d\u60f3\u63db\u884c\u5462?

    print(\"You\")\nprint(\"are\")\nprint(\"my\", end=' ')\nprint(\"special\", end='\\n')\nprint(\"1234\", end=\"5\")\nprint(\"---------\")\n
    ouput
    You\nare\nmy special\n12345---------\n

    \u5728\u9019\u500b\u5947\u602a\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u4f60\u767c\u73fe\u6211\u5728 print \u7684\u62ec\u865f\u4e2d\u591a\u52a0\u4e86\u4e00\u500b end= \u7684\u6771\u897f\uff0c\u8b93 print \u5370\u5b8c\u524d\u9762\u7684\u6771\u897f\u5f8c\uff0c\u518d\u5370\u51fa\u7b49\u65bc\u5f8c\u7684\u6771\u897f\u3002

    You are my special

    \u90a3 \\n \u662f\u4ec0\u9ebc\u6771\u897f?\u4ed6\u662f\u8df3\u812b\u5b57\u5143(Escape Character)\u5bb6\u65cf\u4e2d\u7684\u4e00\u54e1\uff0c\u4f60\u73fe\u5728\u53ea\u8981\u77e5\u9053\u4ed6\u80fd\u5920\u63db\u884c\u3002

    Note

    1. \u96d9\u5f15\u865f/\u55ae\u5f15\u865f\u570d\u4f4f\u7684\u5167\u5bb9\uff0c\u7a31\u70ba\u5b57\u4e32\uff0c\u4f8b\u5982 \"cheung4843\" \u8207 '114514 + 1919810' \uff0c\u4f46\u8a18\u4f4f\u55ae\u96d9\u5f15\u865f\u4e0d\u5f97\u6df7\u7528\u3002
    2. print(x, end=y) \u6703\u5370\u51fa x \uff0c\u518d\u5370\u51fa y\uff0c\u800c y \u9810\u8a2d\u70ba \\n \u4e5f\u5c31\u662f\u63db\u884c\u3002

    @EditTime : 2024-01-25 19:23

    Question

    1. \u90a3\u9ebc \"'\" \u8207 \"\"\" \u662f\u5408\u6cd5\u7684\u5b57\u4e32\u55ce?
    2. print() \u62ec\u865f\u5167\u6c92\u6709\u653e\u6771\u897f\u6703\u5370\u51fa\u4ec0\u9ebc?

    @EditTime : 2024-01-25 19:55

    "},{"location":"fundamental/python/say_hello/#variable_and_input","title":"Variable and Input","text":"

    \u63a5\u4e0b\u4f86\uff0c\u4f86\u9ede\u597d\u73a9\u7684\u3002

    x = 4843\nprint(x)\n\nx = \"Memory Reboot\"\nprint(x)\n\nx = '4843'\nprint(x)\n

    \u6216\u8a31\u4f60\u53ef\u80fd\u6703\u89ba\u5f97\u795e\u5947\uff0c\u70ba\u4ec0\u9ebc x \u53ef\u4ee5\u8b8a\u6210\u6578\u5b57\uff0c\u53c8\u53ef\u4ee5\u8b8a\u6210\u5b57\u4e32\uff0c\u9084\u6709\u70ba\u4ec0\u9ebc\u7b2c\u4e00\u500b\u8207\u7b2c\u4e09\u500b\u7684\u8f38\u51fa\u6703\u662f\u76f8\u540c\u7684\u3002

    \u518d\u4f86\u7528\u4e00\u4e9b old-school \u7684\u6bd4\u55bb\uff0c\u4f60\u53ef\u4ee5\u5c07 x \u60f3\u50cf\u6210\u4e00\u500b\u7bb1\u5b50\uff0c\u800c\u7b49\u865f\u53f3\u908a\u7684\u300c\u503c\u300d\u5c31\u662f\u7bb1\u5b50\u88e1\u88dd\u7684\u6771\u897f\u3002\u65e2\u7136\u7bb1\u5b50\u88e1\u9762\u7684\u6771\u897f\u53ef\u4ee5\u8b8a\uff0c\u90a3\u6211\u662f\u4e0d\u662f\u53ef\u4ee5\u8aaa x \u662f\u4e00\u500b\u8b8a\u6578\u5462?

    \u4f46\u8acb\u4f60\u5148\u5fd8\u6389\u9019\u500b\u6bd4\u55bb\uff0c\u56e0\u70ba\u9019\u500b\u6bd4\u55bb\u4e26\u4e0d\u5b8c\u7f8e\uff0c\u4f46\u6211\u60f3\u4f60\u61c9\u8a72\u80fd\u5920\u7406\u89e3\uff0cx \u662f\u4e00\u500b\u8b8a\u6578\uff0c\u800c = \u662f\u4e00\u500b\u6307\u6d3e\u904b\u7b97\u5b50(assignment operator)\uff0c\u4ed6\u6703\u5c07\u7b49\u865f\u53f3\u908a\u7684\u6771\u897f\u6307\u6d3e\u7d66\u7b49\u865f\u5de6\u908a\u7684\u8b8a\u6578\u3002

    \u8acb\u89c0\u770b\u4e0b\u9762\u7684\u52d5\u756b\u3002

    V\u00d8J, Narvent - Memory Reboot (4K Music Video)

    \u4f46\u662f\u5982\u679c\u6bcf\u6b21\u60f3\u8981\u4fee\u6539 x \u88e1\u9762\u7684\u6771\u897f\uff0c\u96e3\u9053\u90fd\u8981\u5728\u7a0b\u5f0f\u78bc\u4e2d\u4fee\u6539\u55ce?\u80fd\u4e0d\u80fd\u6211\u81ea\u5df1\u4f86\u8f38\u5165\u5462?

    x = input(\"Enter a number: \")\nprint(type(x))\ny = input(\"Enter another number: \")\nz = int(x) + int(y)\nprint(\"The sum is: \", z)\n

    \u5594\u5e79\uff0c\u600e\u9ebc\u4e00\u4e0b\u5b50\u591a\u51fa\u90a3\u9ebc\u591a\u6771\u897f\uff0c\u5225\u614c\uff0c\u6211\u4f86\u89e3\u91cb\uff0c\u4f46\u8acb\u4f60\u5148\u56de\u60f3\u5728\u524d\u4e00\u7bc0\u4e2d\u5b78\u904e\u7684\u6771\u897f\uff0c\u4f60\u53ef\u4ee5\u767c\u73fe input, int, type \u90fd\u662f\u51fd\u5f0f\u3002\u800c input \u62ec\u865f\u4e2d\u7684\u5b57\u4e32\u6703\u986f\u793a\u5728\u63a7\u5236\u53f0\u4e2d\u63d0\u793a\u4f60\u8981\u8f38\u5165\u4ec0\u9ebc\uff0ctype \u5247\u544a\u8a34\u4f60\u62ec\u865f\u4e2d\u7684\u6771\u897f\u662f\u4ec0\u9ebc\u985e\u5225(Class)\uff0c\u6700\u5f8c\uff0cint \u5247\u662f\u628a\u62ec\u865f\u4e2d\u7684\u6771\u897f\u7684\u985e\u5225\u8f49\u63db\u6210\u6574\u6578\u3002

    \u90a3\u70ba\u4ec0\u9ebc\u5370\u51fatype(x) \u5f97\u5230 <class 'str'> \u5462?\u4ee3\u8868 x \u662f\u4e00\u500b\u5b57\u4e32\uff0c\u9019\u662f\u56e0\u70ba input \u7e3d\u662f\u5c07\u4f60\u8f38\u5165\u9032\u4f86\u7684\u6771\u897f\u7576\u6210\u5b57\u4e32\uff0c\u4f46\u6211\u60f3\u8981\u8b93 z = x + y \u9019\u500b\u6578\u5b78\u5f0f\u5b50\u6210\u7acb\uff0c\u6240\u4ee5\u9700\u8981\u7528 int \u4f86\u5c07\u5b57\u4e32\u8f49\u63db\u6210\u6574\u6578\u518d\u9032\u884c\u904b\u7b97\u3002

    \u90a3\u4e0b\u9762\u9019\u500b\u7a0b\u5f0f\u78bc\u7684\u8f38\u51fa\u7d50\u679c\u662f\u4ec0\u9ebc\u5462?

    x = input(\"Enter a number: \")\nprint(type(x))\ny = input(\"Enter another number: \")\nz = x + y\nprint(\"The sum is: \", z)\n

    \u6c92\u932f\uff0c\u5b57\u4e32\u7684\u76f8\u52a0\uff0c\u5c31\u662f\u76f8\u9023\u3002\u90a3\u4f60\u8981\u4e0d\u8981\u8a66\u8a66\u770b\u76f8\u6e1b?

    \u90a3\u5982\u679c\u6211\u4eca\u5929\u60f3\u8981\u4e00\u6b21\u8f38\u5165\u597d\u5e7e\u500b\u5b57\u4e32\uff0c\u6bcf\u4e00\u500b\u5b57\u4e32\u4ee5\u7a7a\u683c\u4f86\u9694\u958b\u5462? \u4f46\u5728\u9019\u4e4b\u524d\uff0c\u6211\u5011\u5148\u4f86\u770b\u4e00\u500b\u5c0f\u7a0b\u5f0f :

    a, b = \"Hello World\".split()\nprint(a)\nprint(b)\n

    \u6211\u77e5\u9053\u602a\u602a\u7684\uff0c\u70ba\u4ec0\u9ebc\u5b57\u4e32\u5f8c\u9762\u63a5\u4e86\u4e00\u500b .split() \u5462?\u5728\u9019\u88e1\u4ed6\u5f88\u50cf\u662f\u51fd\u5f0f\uff0c\u4f46\u53c8\u4e0d\u662f\u51fd\u5f0f\uff0c\u90a3\u4ed6\u53eb\u4ec0\u9ebc\u5462?\u4ed6\u88ab\u7a31\u70ba \"Hello World\" \u9019\u500b\u5b57\u4e32\u7684\u65b9\u6cd5(Method)\uff0c\u4f46\u672a\u4f86\u4f60\u53ef\u80fd\u9084\u6703\u807d\u5230\u985e\u5225\u65b9\u6cd5(Class Method)\uff0c\u4ee5\u53ca\u975c\u614b\u65b9\u6cd5(Static Method) \u7b49\u540d\u8a5e\uff0c\u6211\u6015\u4f60\u6703\u641e\u6df7\uff0c\u6240\u4ee5\u4f60\u5c31\u5148\u8a8d\u9017\u9ede\u5f8c\u9762\u7684\u662f\u300c\u65b9\u6cd5\u300d\u5c31\u597d\u4e86\u3002

    \u800c .split() \u6703\u628a\u5b57\u4e32\u4ee5\u62ec\u865f\u5167\u7684\u6771\u897f\u4f86\u5207\u5272\u5b57\u4e32\u4e26\u56de\u50b3(\u90a3\u4f60\u60f3\u60f3\u62ec\u865f\u5167\u4ec0\u9ebc\u90fd\u6c92\u653e\uff0c\u9810\u8a2d\u6703\u662f\u4ec0\u9ebc?)\uff0c\u800c\u770b\u770b\u7b49\u865f\u5de6\u908a\uff0c\u6211\u7528 a, b \u53bb\u63a5\u8457\uff0c\u9019\u7a31\u70ba\u958b\u7bb1(Unpacking)

    \u90a3\u73fe\u5728\u4f60\u61c9\u8a72\u80fd\u770b\u61c2\u4e0b\u9762\u7684\u7a0b\u5f0f\u78bc\u4e86\uff0c\u56e0\u70ba input() \u4e5f\u6703\u56de\u50b3\u4e00\u500b\u5b57\u4e32\uff0c\u56e0\u6b64\u4ed6\u4e5f\u80fd\u5920\u4f7f\u7528 .split()

    a, b = input().split()\nprint(a)\nprint(b)\n

    Note

    1. input() \u63a5\u53d7\u8f38\u5165\uff0c\u56de\u50b3\u4e00\u500b\u5b57\u4e32\u3002
    2. int(x) \u5c07 x \u8f49\u63db\u6210\u6574\u6578\u3002
    3. type(x) \u56de\u50b3 x \u7684\u985e\u5225\u3002
    4. str.split() \u4ee5\u62ec\u865f\u5167\u7684\u6771\u897f\u4f86\u5207\u5272\u5b57\u4e32\uff0c\u4e26\u56de\u50b3\u3002

    @EditTime : 2024-01-25 22:13

    Question

    1. print(int(input()) + int(input())) \u6703\u5370\u51fa\u4ec0\u9ebc?
    2. 124.spilt(\"1\") \u662f\u5408\u6cd5\u7684\u55ce?
    3. \u770b\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\uff0c\u70ba\u4ec0\u9ebc\u5b83\u5011\u7684\u529f\u80fd\u76f8\u540c\uff0ca \u8207 b \u6210\u529f\u4e92\u63db\u4e86\u5462?
    a, b = 4, 5\nprint(a, b)\na, b = b, a\nprint(a, b)\n
    a, b = 4, 5\nprint(a, b)\ntmp = a\na = b\nb = tmp\nprint(a, b)\n

    @EditTime : 2024-01-25 22:17

    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\u200b\\u3000\\-\u3001\u3002\uff0c\uff0e\uff1f\uff01\uff1b]+","pipeline":["stemmer"]},"docs":[{"location":"","title":"Hello LMcps Book!","text":""},{"location":"#welcome_to_lmcps","title":"Welcome to LMcps!","text":"

    \u9ece\u660e\u8cc7\u8a0a\u793e(LMcps)\u5275\u7acb\u65bc2018\u5e74\uff0c\u6307\u5c0e\u8005\u70ba\u674e\u60e0\u6587\u8001\u5e2b\u3002

    \u672c\u66f8\u7684\u6b63\u78ba\u6253\u958b\u65b9\u5f0f\u662f\u6697\u8272\u6a21\u5f0f\u3002

    print(\"Hello LMcps Book!\")\nprint(\"Welcome to LMcps!\")\n
    "},{"location":"#why_does_it_start","title":"Why does it start?","text":"

    \u57282024/1/25\uff0c\u662f\u75ab\u60c5\u5f8c\uff0c\u7b2c\u4e00\u6b21\u6b77\u5c46\u793e\u54e1\u8fd4\u56de\u6bcd\u6821\u8207\u5b78\u5f1f\u59b9\u5011\u5206\u4eab\u7d93\u9a57\u7684\u65e5\u5b50\uff0c\u5728\u8207\u8001\u5e2b\u53ca\u5b78\u5f1f\u59b9\u5011\u4ea4\u6d41\u5f8c\uff0c\u767c\u73fe\u4e86\u76ee\u524d\u8cc7\u8a0a\u6559\u80b2\u7684\u7a98\u56f0\uff0c\u8af8\u5982\u7db2\u8def\u4e0a\u7684\u8cc7\u6e90\u96d6\u591a\uff0c\u4f46\u4e0d\u6613\u5165\u9580\uff0c\u65bc\u662f\u6c7a\u5b9a\u5beb\u4e00\u672c\u66f8\uff0c\u4ee5\u5927\u91cf\u7684\u5716\u7247\u53ca\u7c21\u55ae\u7684\u6587\u5b57\uff0c\u8b93\u5b78\u5f1f\u59b9\u5011\u80fd\u5920\u5feb\u901f\u5165\u9580\uff0c\u4e26\u4e14\u80fd\u5920\u5728\u77ed\u6642\u9593\u5167\uff0c\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\u8207\u81ea\u4fe1\u3002

    "},{"location":"#content","title":"Content","text":"

    \u9019\u672c\u66f8\u8457\u91cd\u65bc\u61c9\u7528\u9762\uff0c\u4e26\u4e14\u5be6\u4f5c\u70ba\u4e3b\uff0c\u4e5f\u4e26\u975e\u5e36\u4f60\u6253\u7af6\u7a0b\uff0c\u800c\u662f\u5e36\u4f60\u4e86\u89e3\u91cd\u8981\u7684\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5\u3002\u5be6\u4f5c\u8a9e\u8a00\u4ee5Python\u70ba\u4e3b\uff0c\u6703\u6709\u5c11\u6578C++\u7684\u5be6\u4f5c\u3002

    "},{"location":"#contributors","title":"Contributors","text":"

    Success

    1. \u7b2c\u4e8c\u4efb\u793e\u9577
    "},{"location":"license/","title":"License","text":"

    MIT License

    Copyright (c) 2023 Cheung4843

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    "},{"location":"fundamental/","title":"Fundamental","text":"

    \u9019\u88e1\u5c07\u6703\u6559\u4f60\u57fa\u790e\u7684Python\u8207C++\u7684\u57fa\u790e\u8a9e\u6cd5\u3002

    "},{"location":"fundamental/cpp/","title":"C++","text":""},{"location":"fundamental/python/","title":"Python","text":"

    \u55e8\uff0c\u6211\u662f @cheung4843\uff0c\u662fPython\u7cfb\u5217\u7684\u4f5c\u8005\u3002\u5728\u4e00\u958b\u59cb\u57fa\u790e\u8a9e\u6cd5\u7684\u90e8\u5206\u6703\u6559\u5f97\u7279\u5225\u8a73\u7d30\uff0c\u6587\u7ae0\u4e2d\u7684\u5c08\u6709\u540d\u8a5e\u5c07\u6703\u4ee5\u9ec3\u8272\u8207\u7da0\u8272\u6a19\u793a\uff0c\u8acb\u4f60\u7a0d\u5fae\u6ce8\u610f\u4e00\u4e0b\uff0c\u82e5\u4e0d\u61c2\u4e5f\u6c92\u95dc\u4fc2\uff0c\u6211\u6703\u5728\u5f8c\u9762\u7ae0\u7bc0\u518d\u6b21\u63d0\u5230\u3002

    \u5728\u6bcf\u4e00\u500b\u5c0f\u7bc0\u7684\u5f8c\u9762\u90fd\u6703\u6709\u7b46\u8a18\u5340\u4ee5\u53ca\u554f\u984c\u5340\uff0c\u5c24\u5176\u662f\u554f\u984c\u5340\uff0c\u8acb\u4f60\u597d\u597d\u601d\u8003\u3002\u800c\u5728\u6bcf\u4e00\u7bc7\u6587\u7ae0\u6700\u5f8c\u90fd\u6703\u653e\u4e0a\u4e00\u4e9b\u7df4\u7fd2\u984c\uff0c\u8acb\u5617\u8a66\u5b8c\u6210\u4ed6\u5011!

    "},{"location":"fundamental/python/say_hello/","title":"Say Hello to Python!","text":""},{"location":"fundamental/python/say_hello/#first_program","title":"First Program","text":"

    \u55e8\uff0c\u9019\u662f\u4f60\u7b2c\u4e00\u500b Python \u7a0b\u5f0f\uff0c\u5728 Pycharm \u4e2d\u5efa\u7acb\u4e00\u500b main.py \u6a94\u6848\uff0c\u4e26\u5728\u6a94\u6848\u4e2d\u6253\u4e0a :

    # print(\"Hello Cat!\")\nprint(\"Hello World!\")\nprint('Hello Python!')\nprint(\"cheung4843\")\n

    \u6309\u4e0b\u57f7\u884c\u5f8c\uff0c\u4f60\u7684\u63a7\u5236\u53f0(Console)\u5c07\u6703\u5370\u51fa Hello World! \u63a5\u8457\u63db\u884c\uff0c\u518d\u5370\u51fa Hello Python!\uff0c\u63a5\u8457\u518d\u5370\u51fa\u6211 cheung4843\uff0c\u518d\u63db\u884c\u3002

    \u90a3 # print(\"Hello Cat!\") \u662f\u4ec0\u9ebc?\u4ee5\u4e95\u5b57\u865f\u70ba\u958b\u982d\u7684\uff0c\u88ab\u7a31\u70ba\u8a3b\u89e3\uff0c\u4ed6\u4e0d\u6703\u5728\u7a0b\u5f0f\u4e2d\u88ab\u57f7\u884c\uff0c\u800c\u4ed6\u7684\u4f5c\u7528\uff0c\u4f60\u4ee5\u5f8c\u4e00\u5b9a\u80fd\u9ad4\u6703\u3002

    \u4e0d\u66c9\u5f97\u4f60\u662f\u5426\u6709\u767c\u73fe \"Hello World!\" \u8207 'Hello Python!' \u7684\u5dee\u7570?\u7576\u7136\u9664\u4e86\u5b57\u6bcd\u4e0d\u4e00\u6a23\u4e4b\u5916\uff0c\u9084\u6709\u96d9\u5f15\u865f\u8207\u55ae\u5f15\u865f\u7684\u5dee\u5225\uff0c\u4f46\u4ed6\u5011\u90fd\u88ab\u7a31\u70ba\u5b57\u4e32(String)\uff0c\u5728 Python \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6210\u5c0d\u7684\u96d9\u5f15\u865f\u8207\u55ae\u5f15\u865f\u4f86\u8868\u9054\u4e00\u500b\u5b57\u4e32\uff0c\u4f46\u662f\u4e0d\u80fd\u6df7\u7528\uff0c\u4f8b\u5982 :

    print(\"I love cats')\n

    \u57f7\u884c\u5f8c\uff0c\u4f60\u6703\u767c\u73fe\u63a7\u5236\u53f0\u8ddf\u4f60\u5831\u544a\u4e86\u932f\u8aa4\uff0c\u9019\u662f\u8a9e\u6cd5\u932f\u8aa4\uff0c\u800c\u5f8c\u7e8c\u5beb\u7a0b\u5f0f\u7684\u904e\u7a0b\u4e2d\uff0c\u4f60\u5c07\u906d\u9047\u8a31\u591a\u8a9e\u610f\u932f\u8aa4\u3002

    \u90a3\u4f60\u77e5\u9053\u4ec0\u9ebc\u662f\u7a7a\u5b57\u4e32\u55ce?

    print('')\nprint(\"\")\nprint(\"Above are nothing, right?\")\n

    \u57f7\u884c\u5b8c\u5f8c\uff0c\u4f60\u5c31\u77e5\u9053\u7a7a\u5b57\u4e32\u662f\u4ec0\u9ebc\u4e86\u5427?

    \u63a5\u8457\u6211\u5011\u4f86\u8b1b\u8b1b print \u9019\u500b\u6771\u897f\uff0c\u6211\u5011\u5728 Python \u4e2d\u7a31\u4ed6\u70ba\u51fd\u5f0f(Function)\uff0c\u6211\u5011\u8981\u5982\u4f55\u4f7f\u7528\u5462?\u4e5f\u5c31\u662f\u5728\u51fd\u5f0f\u7684\u540d\u7a31\u5f8c\u52a0\u4e0a\u4e00\u500b\u62ec\u865f()\u3002\u800c print \u662f Python \u5167\u5efa\u7d66\u6211\u5011\u7684\u300c\u5de5\u5177\u300d\uff0c\u5c31\u662f\u8aaa\uff0c\u6211\u5011\u4e0d\u77e5\u9053\u4ed6\u662f\u600e\u9ebc\u88ab\u9020\u51fa\u4f86\u7684\uff0c\u6211\u5011\u73fe\u968e\u6bb5\u53ea\u8981\u77e5\u9053\u600e\u9ebc\u7528\u5c31\u597d\uff0c\u6216\u8a31\u4f60\u53ef\u80fd\u807d\u904e\u4e00\u500b\u8001\u6389\u7259\u7684\u6bd4\u55bb\uff0c\u7a31\u51fd\u5f0f\u5c31\u50cf\u662f\u4e00\u500b\u9ed1\u76d2\u5b50\u3002

    \u95dc\u65bc\u51fd\u5f0f(Function)\uff0c\u6211\u6703\u5728\u5f80\u5f8c\u7684\u7ae0\u7bc0\u8ddf\u4f60\u4ecb\u7d39\uff0c\u800c\u73fe\u5728\u4f60\u53ea\u8981\u77e5\u9053 print() \u6703\u5c07\u62ec\u865f\u5167\u7684\u6771\u897f\u5370\u51fa\u4f86\uff0c\u4e26\u63db\u884c\u3002

    \u90a3\u5982\u679c\u6211\u4e0d\u60f3\u63db\u884c\u5462?

    print(\"You\")\nprint(\"are\")\nprint(\"my\", end=' ')\nprint(\"special\", end='\\n')\nprint(\"1234\", end=\"5\")\nprint(\"---------\")\n
    ouput
    You\nare\nmy special\n12345---------\n

    \u5728\u9019\u500b\u5947\u602a\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u4f60\u767c\u73fe\u6211\u5728 print \u7684\u62ec\u865f\u4e2d\u591a\u52a0\u4e86\u4e00\u500b end= \u7684\u6771\u897f\uff0c\u8b93 print \u5370\u5b8c\u524d\u9762\u7684\u6771\u897f\u5f8c\uff0c\u518d\u5370\u51fa\u7b49\u65bc\u5f8c\u7684\u6771\u897f\u3002

    You are my special

    \u90a3 \\n \u662f\u4ec0\u9ebc\u6771\u897f?\u4ed6\u662f\u8df3\u812b\u5b57\u5143(Escape Character)\u5bb6\u65cf\u4e2d\u7684\u4e00\u54e1\uff0c\u4f60\u73fe\u5728\u53ea\u8981\u77e5\u9053\u4ed6\u80fd\u5920\u63db\u884c\u3002

    Note

    1. \u96d9\u5f15\u865f/\u55ae\u5f15\u865f\u570d\u4f4f\u7684\u5167\u5bb9\uff0c\u7a31\u70ba\u5b57\u4e32\uff0c\u4f8b\u5982 \"cheung4843\" \u8207 '114514 + 1919810' \uff0c\u4f46\u8a18\u4f4f\u55ae\u96d9\u5f15\u865f\u4e0d\u5f97\u6df7\u7528\u3002
    2. print(x, end=y) \u6703\u5370\u51fa x \uff0c\u518d\u5370\u51fa y\uff0c\u800c y \u9810\u8a2d\u70ba \\n \u4e5f\u5c31\u662f\u63db\u884c\u3002

    @EditTime : 2024-01-25 19:23

    Question

    1. \u90a3\u9ebc \"'\" \u8207 \"\"\" \u662f\u5408\u6cd5\u7684\u5b57\u4e32\u55ce?
    2. print() \u62ec\u865f\u5167\u6c92\u6709\u653e\u6771\u897f\u6703\u5370\u51fa\u4ec0\u9ebc?

    @EditTime : 2024-01-25 19:55

    "},{"location":"fundamental/python/say_hello/#variable_and_input","title":"Variable and Input","text":""},{"location":"fundamental/python/say_hello/#variable","title":"Variable","text":"

    \u63a5\u4e0b\u4f86\uff0c\u4f86\u9ede\u597d\u73a9\u7684\u3002

    x = 4843\nprint(x)\n\nx = \"Memory Reboot\"\nprint(x)\n\nx = '4843'\nprint(x)\n

    \u6216\u8a31\u4f60\u53ef\u80fd\u6703\u89ba\u5f97\u795e\u5947\uff0c\u70ba\u4ec0\u9ebc x \u53ef\u4ee5\u8b8a\u6210\u6578\u5b57\uff0c\u53c8\u53ef\u4ee5\u8b8a\u6210\u5b57\u4e32\uff0c\u9084\u6709\u70ba\u4ec0\u9ebc\u7b2c\u4e00\u500b\u8207\u7b2c\u4e09\u500b\u7684\u8f38\u51fa\u6703\u662f\u76f8\u540c\u7684\u3002

    \u518d\u4f86\u7528\u4e00\u4e9b old-school \u7684\u6bd4\u55bb\uff0c\u4f60\u53ef\u4ee5\u5c07 x \u60f3\u50cf\u6210\u4e00\u500b\u7bb1\u5b50\uff0c\u800c\u7b49\u865f\u53f3\u908a\u7684\u300c\u503c\u300d\u5c31\u662f\u7bb1\u5b50\u88e1\u88dd\u7684\u6771\u897f\u3002\u65e2\u7136\u7bb1\u5b50\u88e1\u9762\u7684\u6771\u897f\u53ef\u4ee5\u8b8a\uff0c\u90a3\u6211\u662f\u4e0d\u662f\u53ef\u4ee5\u8aaa x \u662f\u4e00\u500b\u8b8a\u6578\u5462?

    \u4f46\u8acb\u4f60\u5148\u5fd8\u6389\u9019\u500b\u6bd4\u55bb\uff0c\u56e0\u70ba\u9019\u500b\u6bd4\u55bb\u4e26\u4e0d\u5b8c\u7f8e\uff0c\u4f46\u6211\u60f3\u4f60\u61c9\u8a72\u80fd\u5920\u7406\u89e3\uff0cx \u662f\u4e00\u500b\u8b8a\u6578\uff0c\u800c = \u662f\u4e00\u500b\u6307\u6d3e\u904b\u7b97\u5b50(Assignment Operator)\uff0c\u4ed6\u6703\u5c07\u7b49\u865f\u53f3\u908a\u7684\u6771\u897f\u6307\u6d3e\u7d66\u7b49\u865f\u5de6\u908a\u7684\u8b8a\u6578\uff0c\u6216\u8005\u8aaa x \u6703\u6307\u5411\u7b49\u865f\u53f3\u908a\u7684\u7269\u4ef6(Object)\u3002

    Quote

    \u5728Python\u4e2d\uff0c\u4e00\u5207\u90fd\u662f\u7269\u4ef6\u3002

    \u8acb\u89c0\u770b\u4e0b\u9762\u7684\u52d5\u756b\u3002

    V\u00d8J, Narvent - Memory Reboot (4K Music Video)

    \u518d\u4f86\u4ecb\u7d39\u5e7e\u7a2e\u4e0d\u540c\u7684\u8b8a\u6578\u985e\u578b\u3002

    a = 114514\nprint(type(a))\nb = 1919810.0\nprint(type(b))\nc = 10e3\nprint(type(c))\nd = \"cheung4843\"\nprint(type(d))\ne = True\nprint(type(e))\nf = False\nprint(type(f))\nh = None\nprint(type(h))\n
    type \u544a\u8a34\u4f60\u62ec\u865f\u4e2d\u7684\u6771\u897f\u662f\u4ec0\u9ebc\u985e\u5225(Class)\u3002

    b \u8207 c \u90fd\u662f\u6d6e\u9ede\u6578(Float)\uff0c\u4e5f\u5c31\u662f\u5c0f\u6578\u9ede\u7684\u6578\u5b57\uff0c\u800c d \u5247\u662f\u5b57\u4e32\uff0ce \u8207 f \u5247\u662f\u5e03\u6797(Boolean)\uff0c\u800c h \u5247\u662f\u7a7a\u503c\u3002

    Note

    1. type(x) \u56de\u50b3 x \u7684\u985e\u5225\u3002
    2. int \u6574\u6578\u3002
    3. float \u6d6e\u9ede\u6578\u3002
    4. str \u5b57\u4e32\u3002
    5. bool \u5e03\u6797\u3002
    6. None \u7a7a\u503c\u3002

    Question

    1. print(type(3 + 4.0)) \u6703\u5370\u51fa\u4ec0\u9ebc?
    2. print(type(3 + True)) \u6703\u5370\u51fa\u4ec0\u9ebc?

    @EditTime : 2024-01-27 16:44

    "},{"location":"fundamental/python/say_hello/#input","title":"Input","text":"

    \u4f46\u662f\u5982\u679c\u6bcf\u6b21\u60f3\u8981\u4fee\u6539 x \u88e1\u9762\u7684\u6771\u897f\uff0c\u96e3\u9053\u90fd\u8981\u5728\u7a0b\u5f0f\u78bc\u4e2d\u4fee\u6539\u55ce?\u80fd\u4e0d\u80fd\u6211\u81ea\u5df1\u4f86\u8f38\u5165\u5462?

    x = input(\"Enter a number: \")\nprint(type(x))\ny = input(\"Enter another number: \")\nz = int(x) + int(y)\nprint(\"The sum is: \", z)\n

    \u5594\u5e79\uff0c\u600e\u9ebc\u4e00\u4e0b\u5b50\u591a\u51fa\u90a3\u9ebc\u591a\u6771\u897f\uff0c\u5225\u614c\uff0c\u6211\u4f86\u89e3\u91cb\uff0c\u4f46\u8acb\u4f60\u5148\u56de\u60f3\u5728\u524d\u4e00\u7bc0\u4e2d\u5b78\u904e\u7684\u6771\u897f\uff0c\u4f60\u53ef\u4ee5\u767c\u73fe input, int, \u90fd\u662f\u51fd\u5f0f\u3002\u800c input \u62ec\u865f\u4e2d\u7684\u5b57\u4e32\u6703\u986f\u793a\u5728\u63a7\u5236\u53f0\u4e2d\u63d0\u793a\u4f60\u8981\u8f38\u5165\u4ec0\u9ebc\uff0cint \u5247\u662f\u628a\u62ec\u865f\u4e2d\u7684\u6771\u897f\u7684\u985e\u5225\u8f49\u63db\u6210\u6574\u6578\u3002

    \u90a3\u70ba\u4ec0\u9ebc\u5370\u51fatype(x) \u5f97\u5230 <class 'str'> \u5462?\u4ee3\u8868 x \u662f\u4e00\u500b\u5b57\u4e32\uff0c\u9019\u662f\u56e0\u70ba input \u7e3d\u662f\u5c07\u4f60\u8f38\u5165\u9032\u4f86\u7684\u6771\u897f\u7576\u6210\u5b57\u4e32\uff0c\u4f46\u6211\u60f3\u8981\u8b93 z = x + y \u9019\u500b\u6578\u5b78\u5f0f\u5b50\u6210\u7acb\uff0c\u6240\u4ee5\u9700\u8981\u7528 int \u4f86\u5c07\u5b57\u4e32\u8f49\u63db\u6210\u6574\u6578\u518d\u9032\u884c\u904b\u7b97\u3002

    \u90a3\u4e0b\u9762\u9019\u500b\u7a0b\u5f0f\u78bc\u7684\u8f38\u51fa\u7d50\u679c\u662f\u4ec0\u9ebc\u5462?

    x = input(\"Enter a number: \")\nprint(type(x))\ny = input(\"Enter another number: \")\nz = x + y\nprint(\"The sum is: \", z)\n

    \u6c92\u932f\uff0c\u5b57\u4e32\u7684\u76f8\u52a0\uff0c\u5c31\u662f\u76f8\u9023\u3002\u90a3\u4f60\u8981\u4e0d\u8981\u8a66\u8a66\u770b\u76f8\u6e1b?

    \u63a5\u4e0b\u4f86\u6211\u5011\u4f86\u505a\u500b\u6709\u8da3\u7684\u5be6\u9a57\uff0c\u9806\u4fbf\u8a8d\u8b58\u4e00\u4e0b f-string

    a = 3.5\nb = int(a)\nprint(f'The value of b is {b}, and its type is {type(b)}')\nc = float(b)\nprint(f'The value of c is {c}, and its type is {type(c)}')\nprint(b == c)\n

    \u90a3 f-string \u662f\u4ec0\u9ebc\u6771\u897f\u5462?\u4ed6\u662f\u4e00\u7a2e\u5b57\u4e32\u683c\u5f0f\u5316(String Formatting)\u7684\u65b9\u6cd5\uff0c\u4ed6\u6703\u5c07\u62ec\u865f\u5167\u7684\u6771\u897f\u8f49\u63db\u6210\u5b57\u4e32\uff0c\u4e26\u5c07\u5b57\u4e32\u4e2d\u7684 {} \u66ff\u63db\u6210\u62ec\u865f\u5167\u7684\u6771\u897f\u3002

    \u800c\u57f7\u884c\u5b8c\u7a0b\u5f0f\u78bc\u5f8c\uff0c\u4f60\u6703\u767c\u73fe b \u8207 c \u7684\u985e\u5225\u4e0d\u540c\uff0c\u4f46\u4ed6\u5011\u7684\u503c\u537b\u76f8\u540c\uff0c\u9019\u662f\u56e0\u70ba int() \u8207 float() \u90fd\u662f\u5c07\u62ec\u865f\u5167\u7684\u6771\u897f\u8f49\u63db\u6210\u6574\u6578\u8207\u6d6e\u9ede\u6578\uff0c\u800c int() \u6703\u5c07\u6d6e\u9ede\u6578\u7684\u5c0f\u6578\u9ede\u6368\u53bb\uff0c\u800c float() \u5247\u6703\u5c07\u6574\u6578\u8f49\u63db\u6210\u6d6e\u9ede\u6578\u3002

    \u90a3\u9ebc b == c \u662f\u4ec0\u9ebc\u610f\u601d\u5462?\u4ed6\u662f\u4e00\u500b\u6bd4\u8f03\u904b\u7b97\u5b50(Comparison Operator)\uff0c\u4ed6\u6703\u6bd4\u8f03\u7b49\u865f\u5de6\u53f3\u5169\u908a\u7684\u6771\u897f\u662f\u5426\u76f8\u7b49\uff0c\u5982\u679c\u76f8\u7b49\uff0c\u5247\u56de\u50b3 True\uff0c\u5426\u5247\u56de\u50b3 False\u3002

    \u90a3\u5982\u679c\u6211\u4eca\u5929\u60f3\u8981\u4e00\u6b21\u8f38\u5165\u597d\u5e7e\u500b\u5b57\u4e32\uff0c\u6bcf\u4e00\u500b\u5b57\u4e32\u4ee5\u7a7a\u683c\u4f86\u9694\u958b\u5462? \u4f46\u5728\u9019\u4e4b\u524d\uff0c\u6211\u5011\u5148\u4f86\u770b\u4e00\u500b\u5c0f\u7a0b\u5f0f :

    a, b = \"Hello World\".split()\nprint(a)\nprint(b)\n

    \u6211\u77e5\u9053\u602a\u602a\u7684\uff0c\u70ba\u4ec0\u9ebc\u5b57\u4e32\u5f8c\u9762\u63a5\u4e86\u4e00\u500b .split() \u5462?\u5728\u9019\u88e1\u4ed6\u5f88\u50cf\u662f\u51fd\u5f0f\uff0c\u4f46\u53c8\u4e0d\u662f\u51fd\u5f0f\uff0c\u90a3\u4ed6\u53eb\u4ec0\u9ebc\u5462?\u4ed6\u88ab\u7a31\u70ba \"Hello World\" \u9019\u500b\u5b57\u4e32\u7684\u65b9\u6cd5(Method)\uff0c\u4f46\u672a\u4f86\u4f60\u53ef\u80fd\u9084\u6703\u807d\u5230\u985e\u5225\u65b9\u6cd5(Class Method)\uff0c\u4ee5\u53ca\u975c\u614b\u65b9\u6cd5(Static Method) \u7b49\u540d\u8a5e\uff0c\u6211\u6015\u4f60\u6703\u641e\u6df7\uff0c\u6240\u4ee5\u4f60\u5c31\u5148\u8a8d\u9017\u9ede\u5f8c\u9762\u7684\u662f\u300c\u65b9\u6cd5\u300d\u5c31\u597d\u4e86\u3002

    \u800c .split() \u6703\u628a\u5b57\u4e32\u4ee5\u62ec\u865f\u5167\u7684\u6771\u897f\u4f86\u5207\u5272\u5b57\u4e32\u4e26\u56de\u50b3(\u90a3\u4f60\u60f3\u60f3\u62ec\u865f\u5167\u4ec0\u9ebc\u90fd\u6c92\u653e\uff0c\u9810\u8a2d\u6703\u662f\u4ec0\u9ebc?)\uff0c\u800c\u770b\u770b\u7b49\u865f\u5de6\u908a\uff0c\u6211\u7528 a, b \u53bb\u63a5\u8457\uff0c\u9019\u7a31\u70ba\u958b\u7bb1(Unpacking)

    \u90a3\u73fe\u5728\u4f60\u61c9\u8a72\u80fd\u770b\u61c2\u4e0b\u9762\u7684\u7a0b\u5f0f\u78bc\u4e86\uff0c\u56e0\u70ba input() \u4e5f\u6703\u56de\u50b3\u4e00\u500b\u5b57\u4e32\uff0c\u56e0\u6b64\u4ed6\u4e5f\u80fd\u5920\u4f7f\u7528 .split()

    a, b = input().split()\nprint(a)\nprint(b)\n

    Note

    1. input() \u63a5\u53d7\u8f38\u5165\uff0c\u56de\u50b3\u4e00\u500b\u5b57\u4e32\u3002
    2. int(x) \u5c07 x \u8f49\u63db\u6210\u6574\u6578\u3002
    3. float(x) \u5c07 x \u8f49\u63db\u6210\u6d6e\u9ede\u6578\u3002
    4. str.split() \u4ee5\u62ec\u865f\u5167\u7684\u6771\u897f\u4f86\u5207\u5272\u5b57\u4e32\uff0c\u4e26\u56de\u50b3\u3002

    @EditTime : 2024-01-25 22:13

    Question

    1. print(int(input()) + int(input())) \u6703\u5370\u51fa\u4ec0\u9ebc?
    2. 124.spilt(\"1\") \u662f\u5408\u6cd5\u7684\u55ce?
    3. bool(0) \u8207 bool(1) \u6703\u56de\u50b3\u4ec0\u9ebc?
    4. \u770b\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\uff0c\u70ba\u4ec0\u9ebc\u5b83\u5011\u7684\u529f\u80fd\u76f8\u540c\uff0ca \u8207 b \u6210\u529f\u4e92\u63db\u4e86\u5462?
    a, b = 4, 5\nprint(a, b)\na, b = b, a\nprint(a, b)\n
    a, b = 4, 5\nprint(a, b)\ntmp = a\na = b\nb = tmp\nprint(a, b)\n

    @EditTime : 2024-01-25 22:17

    "},{"location":"fundamental/python/say_hello/#practice","title":"Practice","text":"

    \u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u5b78\u5230\u4e86:

    Summary

    1. \u5982\u4f55\u4f7f\u7528 print() \u8207 input()\u3002
    2. \u77e5\u9053\u8b8a\u6578\u7684\u6982\u5ff5\u3002
    3. \u77e5\u9053 type(x) \u8207 int(x), float(x) \u7684\u7528\u9014\u3002
    4. \u77e5\u9053 str.split() \u7684\u7528\u9014\u3002
    5. \u77e5\u9053\u5982\u4f55\u4f7f\u7528 f-string\u3002

    \u90a3\u73fe\u5728\u4f60\u53ef\u4ee5\u8a66\u8a66\u770b\u4ee5\u4e0b\u7684\u984c\u76ee\u4e86\u3002

    ZeroJudge - a001. \u54c8\u56c9

    Reference code
    word = input()\nprint(f'hello, {word}')\n

    @EditTime : 2024-01-27 17:02

    "}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 702e550..aedd3db 100755 Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ