カリキュラムリファレンスリソース
Pythonドキュメント
https://www.python.org/doc/
Pythonがダウンロードをリリース
https://www.python.org/downloads/
初心者向けPythonガイド
https://www.python.org/about/gettingstarted/
PythonWikiビギナーズガイド
https://wiki.python.org/moin/BeginnersGuide
最初のステップ
定義された関数
拡張可能なプログラミングの中核は、関数の定義です。 Pythonでは、必須およびオプションの引数、キーワード引数、さらには任意の引数リストを使用できます。 Python3での関数の定義の詳細
# Python 3: Fibonacci series up to n
>>> def fib(n):
>>> a, b = 0, 1
>>> while a < n:
>>> print(a, end=' ')
>>> a, b = b, a+b
>>> print()
>>> fib(1000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
複合データ型
リスト(他の言語では配列として知られています)は、Pythonが理解する複合データ型のXNUMXつです。 リストは、他の組み込み関数を使用して、インデックス付け、スライス、および操作できます。 Python3のリストの詳細
# Python 3: List comprehensions
>>> fruits = ['Banana', 'Apple', 'Lime']
>>> loud_fruits = [fruit.upper() for fruit in fruits]
>>> print(loud_fruits)
['BANANA', 'APPLE', 'LIME']
# List and the enumerate function
>>> list(enumerate(fruits))
[(0, 'Banana'), (1, 'Apple'), (2, 'Lime')]
直感的な解釈
Pythonを使用すると計算が簡単になり、式の構文が簡単になります。演算子 +
, -
, *
& /
期待どおりに機能します。 括弧 ()
グループ化に使用できます。 Python3の簡単な数学関数の詳細.
# Python 3: Simple arithmetic
>>> 1/2
0.5
>>> 2 ** 3
8
>>> 17/3 # classic division returns a float
5.666666666666667
>>> 17 // 3 # floor division
5
すばやく簡単に学ぶ
他の言語の経験豊富なプログラマーはPythonをすぐに習得でき、初心者はクリーンな構文とインデント構造を簡単に習得できます。 食欲をそそる Python3の概要をご覧ください。
# Python 3: Simple output (with Unicode)
>>> print("Hello, I'm Python!")
Hello, I'm Python!
# Input, assignment
>>> name = input('What is your name?n')
>>> print('Hi, %s.' % name)
What is your name?
Python
Hi, Python.
あなたが期待するすべての流れ
Pythonは、他の言語が話す通常の制御フローステートメントを知っています— if
, for
, while
& range
—もちろん、独自のひねりがいくつかあります。 Python3のその他の制御フローツール
# For loop on a list
>>> numbers = [2, 4, 6, 8]
>>> product = 1
>>> for number in numbers:
... product = product * number
...
>>> print('The product is:', product)
The product is: 384
EITC/CP/PPF Python プログラミングの基礎プログラムの完全なオフライン自己学習準備資料を PDF ファイルでダウンロードします。