マインドマップギャラリー 人工知能プログラミングの学習:Pythonの主な構文と例
これは、Pythonに関するマインドマップ、メインコンテンツ:入力、データ構造の比較、読書、判断、操作、辞書、ループ、配列、スペース、変数、タイプ、印刷に関するマインドマップです。
2025-02-06 11:35:30 に編集されましたRumi: 10 dimensions of spiritual awakening. When you stop looking for yourself, you will find the entire universe because what you are looking for is also looking for you. Anything you do persevere every day can open a door to the depths of your spirit. In silence, I slipped into the secret realm, and I enjoyed everything to observe the magic around me, and didn't make any noise. Why do you like to crawl when you are born with wings? The soul has its own ears and can hear things that the mind cannot understand. Seek inward for the answer to everything, everything in the universe is in you. Lovers do not end up meeting somewhere, and there is no parting in this world. A wound is where light enters your heart.
Chronic heart failure is not just a problem of the speed of heart rate! It is caused by the decrease in myocardial contraction and diastolic function, which leads to insufficient cardiac output, which in turn causes congestion in the pulmonary circulation and congestion in the systemic circulation. From causes, inducement to compensation mechanisms, the pathophysiological processes of heart failure are complex and diverse. By controlling edema, reducing the heart's front and afterload, improving cardiac comfort function, and preventing and treating basic causes, we can effectively respond to this challenge. Only by understanding the mechanisms and clinical manifestations of heart failure and mastering prevention and treatment strategies can we better protect heart health.
Ischemia-reperfusion injury is a phenomenon that cellular function and metabolic disorders and structural damage will worsen after organs or tissues restore blood supply. Its main mechanisms include increased free radical generation, calcium overload, and the role of microvascular and leukocytes. The heart and brain are common damaged organs, manifested as changes in myocardial metabolism and ultrastructural changes, decreased cardiac function, etc. Prevention and control measures include removing free radicals, reducing calcium overload, improving metabolism and controlling reperfusion conditions, such as low sodium, low temperature, low pressure, etc. Understanding these mechanisms can help develop effective treatment options and alleviate ischemic injury.
Rumi: 10 dimensions of spiritual awakening. When you stop looking for yourself, you will find the entire universe because what you are looking for is also looking for you. Anything you do persevere every day can open a door to the depths of your spirit. In silence, I slipped into the secret realm, and I enjoyed everything to observe the magic around me, and didn't make any noise. Why do you like to crawl when you are born with wings? The soul has its own ears and can hear things that the mind cannot understand. Seek inward for the answer to everything, everything in the universe is in you. Lovers do not end up meeting somewhere, and there is no parting in this world. A wound is where light enters your heart.
Chronic heart failure is not just a problem of the speed of heart rate! It is caused by the decrease in myocardial contraction and diastolic function, which leads to insufficient cardiac output, which in turn causes congestion in the pulmonary circulation and congestion in the systemic circulation. From causes, inducement to compensation mechanisms, the pathophysiological processes of heart failure are complex and diverse. By controlling edema, reducing the heart's front and afterload, improving cardiac comfort function, and preventing and treating basic causes, we can effectively respond to this challenge. Only by understanding the mechanisms and clinical manifestations of heart failure and mastering prevention and treatment strategies can we better protect heart health.
Ischemia-reperfusion injury is a phenomenon that cellular function and metabolic disorders and structural damage will worsen after organs or tissues restore blood supply. Its main mechanisms include increased free radical generation, calcium overload, and the role of microvascular and leukocytes. The heart and brain are common damaged organs, manifested as changes in myocardial metabolism and ultrastructural changes, decreased cardiac function, etc. Prevention and control measures include removing free radicals, reducing calcium overload, improving metabolism and controlling reperfusion conditions, such as low sodium, low temperature, low pressure, etc. Understanding these mechanisms can help develop effective treatment options and alleviate ischemic injury.
Python
印刷
引用符は文字列出力です
print( "3*2")出力は3*2です
引用符なしの出力
印刷(3*2)出力結果は6です
10のパワーへの印刷(5 ** 10)5 //それは処方箋です
3つの引用により、ラインブレークが可能になります
印刷(f "これは3x2結果:{3 * 2}") これは3x2の結果です:6
print( "これは3x2の結果です:{3 * 2}") これは3x2の結果です:{3 * 2}
F:特別なフォーマットがあります{}:内部は二重引用符のある文字列の影響を受けません
タイプ
Type()関数は、主にオブジェクトのタイプを返すために使用される組み込み関数であり、プログラミングプロセス中に開発者が適切な操作と処理を実行するために、変数、オブジェクトなどのデータタイプを理解するのに役立ちます。
integer string decimal number list bool logic true or fals
タイプ( "2.8")strを返します
タイプ(2.8)フロートを返します
変数
変数の名前にはスペースがありません
年齢= 3 * 5 印刷(f "le age:{age}") Le Age:15
配列
number = ["1"、 "2"、 "3"]] 印刷(f "これは{numberr}"です) これは['1'、 '2'、 '3']です
[]は配列を表します
number = ["1"、 "2"、 "3"]] print(f "これは{number [0]}"です) これは1です
配列内の数字を個別に呼び出し、0からカウントします
number = ["1"、 "2"、 "3"]] number.append( "4") 印刷(番号) ['1'、 '2'、 '3'、 '4']
配列を追加します
辞書
辞書は、各キー値ペアがキーと関連する値(値)で構成されています。巻き毛のブレース{}。
辞書を作成します
#3つのキー価値ペアを含む辞書を作成します person = {"name": "Alice"、 "age":25、 "City": "New York"}
#キーワードパラメーターを使用して辞書を作成します 学生= dict(name = "bob"、grade = 80) #キー価値のペアのタプルを含むリストから辞書を作成する colors = dict([( "red"、1)、( "green"、2)、( "Blue"、3)))
辞書にアクセスしてください
person = {"name": "Alice"、 "age":25、 "City": "New York"} print(person ["name"])#出力:Alice
印刷(人)はすべての辞書を出力します
辞書を変更します
person = {"name": "alice"、 "age":25} #要素を追加します 人["city"] =「ニューヨーク」 #要素を変更します 人["age"] = 26 print(person)#output:{'name': 'alice'、 'age':26、 'City': 'New York'}
要素を削除します
person = {"name": "Alice"、 "age":25、 "City": "New York"} del person ["city"] print(person)#output:{'name': 'alice'、 'age':25}
データ構造の比較
リスト
正方形の括弧[]で表される可変秩序化されたシーケンスです。
my_list = [1、2、3、4] my_list.append(5)
タプル(タプル)
括弧()で表される不変の秩序化されたシーケンスです。
my_tuple =(1、2、3)
辞書
巻き毛のブレースで表されるキー価値のペアの順序付けられていないセットです{}
my_dict = {"name": "alice"、 "age":20} print(my_dict ["name"])
セット(セット)
は、巻き毛のブレース{}またはset()関数で作成された、順序付けられていないユニークな要素のコレクションです。
my_set = {1、2、3、3} print(my_set)
スペース
年齢= 10 年齢の場合> = 18: #インデントされたコードは、条件が真のときに実行されます print( "smoke can Smoke") print( "あなたは飲むことができます") あなたは飲むことができます
スペースは非常に重要であり、関数関数の範囲を表しています。
裁判官
a = 1 b = 2 a> bの場合: print( "a is big") それ以外: print( "b is big") print( "これは結果です") Bは大きいです これが結果です
場合:else:
スコア= 85 スコアの場合> = 90: 印刷( "優れた") Elifスコア> = 80: print( "good") Elifスコア> = 60: print( "pass") それ以外: print( "failed")
Elif:IFステートメントの後に複数の条件分岐を追加します。
その他:以前のIFおよびELIF条件が満たされていないすべてのケースに対処するために使用されます。以前のすべての条件がfalseである限り、elseコードブロックの内容が実行される限り、追加の条件を指定する必要はありません。
サイクル
number_list = ["1"、 "2"、 "3"、 "4"]] number_listの番号の場合: 印刷(f "これは{number}") これは1です これは2です これは3です これは4です
ステートメントループ実行のため
number_list = ["1"、 "2"、 "3"、 "4"]] インデックスの場合、列挙の数字(number_list、start = 1): print(f "{index} is {number}") 最初のものは1です 2番目は2です 3つ目は3です 4番目は4です
列挙:シーケンスのインデックス。インデックスは、enumerate()関数によって生成されるインデックス値です
number_list = ["1"、 "2"、 "3"、 "4"]] インデックスの場合、列挙の数字(number_list): index == 2の場合: number_list [index] = "修正値" print(number_list) ['1'、 '2'、 '修正値'、 '4']
インデックス値は非常に重要であり、特定の場所で操作をトリガーできます。
==は比較演算子です
手術
比較演算子
a = 1 b = 2 印刷(a> b) 間違い
== 2つの値が等しいかどうかを判断する5 == 3結果は偽です != 2つの値が等しくないかどうかを判断する5!= 3結果は真です >左側の値が右の値よりも大きいかどうかを判断します5> 3結果が真です <左側の値が右の値よりも小さいかどうかを判断します5 <3結果は偽です > =左側の値が右の値以上であるかどうかを判断します5> = 3結果は真です <=左側の値が右側の値よりも低いかどうかを判断します5 <= 3結果は偽です
#ユーザーに整数を入力するように求めます number = int(input( "整数を入力してください:")) #整数が偶数であるかどうかを判断します 数字%2 == 0の場合: print(f "{number}は偶数です。") それ以外: print(f "{number}は奇数です。")
==パスワード検証などに使用できます。
算術演算子
追加、2つの数字を追加またはスプライスするために使用されます。結果は8です。結果は「Hello World」です。 - 2つの数値を差し引くために使用される減算5-3は2です * 2つの数値を掛けるために使用される乗算5 * 3「ABC」 * 3。 /分割、戻り浮動点結果5/3結果は1.666666666666666666667です //分割、商の整数部分を返します5 // 3結果は1です %弾性率を取り、部門5%の残りを返します3は2です **電力操作、数字5の指定された電力を計算します** 3結果は125です
論理演算子
a = 1 b = 2 印刷((aまたはb)> 1) 間違い
そしてロジックと、結果は両方の条件が真である場合にのみ真です または論理的または、真実の条件がある限り、結果は真です 条件に論理的に言及されていない(5> 3)結果は偽です
メンバーオペレーター
値がシーケンス、セット、または辞書(判断キー)にある場合、[1、2、3]でtrue 3を返します結果はtrueです 値がシーケンス、セット、または辞書(判断キー)にない場合は、[1、2、3]にtrue 4を返します。結果はtrueです
アイデンティティオペレーター
2つのオブジェクトが同じであるかどうかを決定します 2つのオブジェクトが同じではないかどうかを判断しません。[1、2]
読む
#ファイルを開きます file = open( 'emple.txt'、 'r'、encoding = 'utf-8') #ファイルコンテンツ全体を読み取ります content = file.read() 印刷(コンテンツ) #ファイルを閉じます file.close()
読んだ後、閉じたファイルでそれを使用してメモリを解放します
open( 'embles.txt'、 'r'、encoding = 'utf-8')としてファイルとして: content = file.read() 印刷(コンテンツ)
実際の作業でより多くの使用を行うと、読んだ後に自動的に閉じることができます。
試す: open( 'embles.txt'、 'r'、encoding = 'utf-8')としてファイルとして: content = file.read() 印刷(コンテンツ) filenotfounderrorを除く: print( "ファイルが見つかりません、ファイルパスを確認してください。")
ファイルが存在しない場合、FilenotFounderror例外がスローされます。この例外は、Try-Exectステートメントを使用してキャッチして処理できます。
入力
#ユーザーに名前を入力するように求めます name = input( "あなたの名前を入力してください:") #出力の挨拶 print(f "hello、{name}!pythonを学ぶためのようこそ。")
入力()関数は、ユーザーから入力を取得し、ユーザーが入力した内容を文字列として返すために使用されます。
#最初の番号を入力するようにユーザーに促します num1 = float(input( "最初の番号を入力してください:")) #ユーザーに2番目の番号を入力するように求めます num2 = float(input( "2番目の番号を入力してください:")) #2つの数値の合計を計算します sum_result = num1 num2 #出力計算結果 print(f "{num1}および{num2} sum is:{sum_result}")
float()関数は、数値計算のためにユーザーが入力した文字列をフローティングポイント番号に変換します。