Python3(6)

%360:Python3(6)

%361:【[%340]】の部分コピー
`▼
--------------------------------------------------------------------------------
(0)「(1)①」の最大公約数の計算法を
  「gcd(12, 3)」「gcd(105, 5)」「gcd(851, 185)」の計算でデバッグ.
(1)参考資料
 ①「Tiny_Python試用録(7)★」@
https://www.blogger.com/blog/post/edit/6859150935899261916/2463065428668505071
 ②https://qiita.com/kinpira/items/505bccacb2fba89c0ff0
・スフィンクスでドキュメント作成からWeb公開
(2)%6741(7)のスクリプトのコピー

 \n------------------------------------
 \n q = (851, )
 \n r = (185, )
 \n k = 1
 \n while r[k] > 0 :
 \n    q[k] = q[k-1] / r[k] 
 \n    r[k] = q[k-1] - q[k] * r[k]
 \n    k = k + 1
 \n continue
 \n 
 \n print(q[k])
 \n------------------------------------

(3)print [q[k] for k in range(len(q))]/*「リストの内包表記★」*/の実行結果★http://www.tohoho-web.com/python/list.html#comprehension
 ①「gcd(12, 3)」⇒「」
 ②「gcd(105, 5)」⇒「」
 ③「gcd(851, 185)」⇒「」
(4)「%6741.docx」の「`」,「_」をスペースで置換する前のスクリプトは
 \n------------------------------------
 \n_ q = `(_851,_ `)_
 \n_ r = `(_185,_ `)_
 \n_ k = 1
 \n_ `while_ r[k] > 0 `:_
 \n__   q[k] = q[k-1] / r[k]
 \n__   r[k] = q[k-1] - q[k] * r[k-1]
 \n__   k = k + 1
 \n__   break_
 \n__`else:_
 \n__   print(q[k])
 \n------------------------------------
 と等価/*〔行頭のレベルが「3」のときは「\n__   _   」〕*/
 ・フォントを「Courier」に変換しています.
(5)「print(q[k])「print [q[k] for k in range(len(q))]」/*「(3)」*/
(6)試行中の「IDLE」のエラーメッセージ
 ①TypeError: 'tuple' object does not support item assignment
 「q[k]=q[k-1]/r[k-1]」
 ②SyntaxError: 'return' outside function/*〔削除済〕*/
 「exit(1)」も不可
(7)「(6)」のテストスクリプト
 \n------------------------------------
 \n q = (12, )
 \n r = (3, )
 \n k = 1
 \n while_ r[k-1] > 0 :

 \n   q[k] = q[k-1] / r[k-1]
 \n   r[k] = q[k-1] - q[k] * r[k-1]
 \n   k = k+1
 \n   break
 \n else:
 \n   print(q[k])
 \n------------------------------------
--------------------------------------------------------------------------------
`▲作業中/*「(3)」*/

%362:SimplyStructuredTextの概略仕様
`▼
--------------------------------------------------------------------------------
(0)「*.rst」とは異なる仕様です./*〔「*.sst」と略記〕*/
 ①「Python」の予約語「□」を「`_」で明示.
 ②「`」,「_」をスペースで置換すると慣用記法に縮退.
(1)参考資料/*「*.rst」*/
 ①「Python.org」@
https://www.python.org/dev/peps/pep-0287/
 ②「Sphinx.org」@
https://sphinx-users.jp/articles/expertpython/restructuredtext.html
 ③「Qiita.com」@
https://qiita.com/kinpira/items/505bccacb2fba89c0ff0
(2)[%361](4)も「*.sst」の一例

 \n------------------------------------
 \n_ q = `(_851,_ `)_
 \n_ r = `(_185,_ `)_
 \n_ k = 1
 \n_ `while_ r[k] > 0 `:_
 \n__   q[k] = q[k-1] / r[k-1]
 \n__   r[k] = q[k-1] - q[k] * r[k-1]
 \n__   k = k + 1
 \n__   `break_
 \n_ `else:_
 \n__   print(q[k])
 \n------------------------------------
(3)別の例:[%662]⑧デリミタ`{_`}_」,「`(_`)_」,「`[_`]_」,
;_」,「:_」,「,_」を用いて着色すると構文が分かり易くなる.
・リスト:a = `[_10,_20,_30,_40`]_
・タプル:a = `(_10,_20,_30,_40`)_
・辞書 :d = `{_'Yamada': 30,_'Suzuki': 40,_'Tanaka': 80`}_
・出典 :「http://www.tohoho-web.com/python/list.html#list
(4)Cのプログラムで多用されるデリミタ「,」,「;」を「,_」,「;_」で表示するので
 「_」をスペースで置換した後ではスクリプトが見やすくなる.
  /*〔「Python」では「:」はデリミタではなくて予約語〕*/
(5)「(2)」の原文(非着色)は[%361](2)
  /*〔背景色は初心者用のオプション〕*/
--------------------------------------------------------------------------------
`▲

%367:Supplement to【[%362]】in English
`▼
--------------------------------------------------------------------------------
(0)「*.sst」(SimplyStructuredText) is specified as follows.
 ①Let「□」be a reserved word of Python, which is expressed as
  「`□_」in 「*.sst」
 ②If every「`」and「_」are replaced by 「 」(space),
  then「*.sst」scripts reduced to that of Formal_Python(by Python.org).
 ③Background color is an option for beginners.
(1)references about「*.rst」
 ①「Python.org」@
https://www.python.org/dev/peps/pep-0287/
 ②「Sphinx.org」@
https://sphinx-users.jp/articles/expertpython/restructuredtext.html
 ③「Qiita.com」@
https://qiita.com/kinpira/items/505bccacb2fba89c0ff0
(2)The script in[%362](2)is an example of「*.sst」
(3)The script in[%362](3)is another example of「*.sst」
(4)Since「*.sst」is quite different from 「*.rst」,
  this blog continue to use「*.sst」as a fork of Formal_Python.
(5)A roadmap of this blog is
 ①Formal_Python ⊂ Courier_Python ⊂ Decimal_Python
 ②Octal_Python ⊂ Kanji_Python ⊂ Regional_Python
 ③Final Goal is to make「Learning Galois Theory with Python.pdf」,
  combining「Galois-□.pdf」in the file「OCNマイポケット★」
https://www.blogger.com/blog/post/edit/6859150935899261916/4202198499080205759
(6)The following files are copied from Google Drive
★https://www.dropbox.com/s/lygf1yjfayas6cx/Galois-1.pdf?dl=0
★https://www.dropbox.com/s/vl0fwy8ck4pxyen/Galois-2.pdf?dl=0
★https://www.dropbox.com/s/xzsexfpqyhg3tvk/Galois-3.pdf?dl=0
--------------------------------------------------------------------------------
`▲

%369:EOF(@L42)

コメント

このブログの人気の投稿

「日記帳(2023 冬)」

ブログの教材で学ぶMATH(1)