スライス演算子とステップ演算子:
例:
名前 = 'abcdefghijklmn'
名前[2:8] -->スライス演算子 --> シーケンスの一部を抽出するために使用されます。
名前[2:8:3] -->ステップ演算子-->ステップ演算子はインデックス間の間隔を定義します。正のステップは前進し、負のステップは後退します。
1) 次の出力を取得する構文:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
方法:1(2つの変数を使用)
start, end = 1, 6 while end>1: for num in range(start,end): print(num, end=' ') print() end-=1
方法:2(単一変数を使用)
end = 6 while end>1: for num in range(1,end): print(num, end=' ') print() end-=1
方法:3(変数を使用しない)
for end in range(6,1,-1): for num in range(1,end): print(num, end=' ') print()
方法:4
for row in range(5): for col in range(5-row): print(col+1, end=' ') print()
出力:
1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
2) 次の出力を取得する構文:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
for row in range(2,7): for col in range(1,row): print(col,end=' ') print()
出力:
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
3) 次の出力を取得する構文:
2 4 6 8 10
2 4 6 8
2 4 6
2 4
2
for row in range(5): for col in range(5-row): print((col+1)*2, end=' ') print()
出力:
2 4 6 8 10 2 4 6 8 2 4 6 2 4 2
4) 次の出力を取得する構文:
1 2 3 4 5
2 4 6 8
3 6 9
4 8
5
for row in range(5): for col in range(5-row): print((col+1)*(row+1), end=' ') print()
出力:
1 2 3 4 5 2 4 6 8 3 6 9 4 8 5
タスク:
紙から手を出さずにこの「コーラム」を描きます:
以上がPython Day-Loop-Slicing & step 演算子、パターン形成、タスクの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

Pythonは解釈された言語ですが、コンパイルプロセスも含まれています。 1)Pythonコードは最初にBytecodeにコンパイルされます。 2)ByteCodeは、Python Virtual Machineによって解釈および実行されます。 3)このハイブリッドメカニズムにより、Pythonは柔軟で効率的になりますが、完全にコンパイルされた言語ほど高速ではありません。

useaforloopwhenteratingoverasequenceor foraspificnumberoftimes; useawhileloopwhentinuninguntinuntilaConditionismet.forloopsareidealforknownownownownownownoptinuptinuptinuptinuptinutionsituations whileoopsuitsituations withinterminedationations。

pythonloopscanleadtoErrorslikeinfiniteloops、ModifiningListsDuringiteration、Off-Oneerrors、Zero-dexingissues、およびNestededLoopinefficiencies.toavoidhese:1)use'i

forloopsareadvastountousforknowterations and sequences、offeringsimplicityandeadability;

pythonusesahybridmodelofcompilation andtertation:1)thepythoninterpretercompilessourcodeodeplatform-indopent bytecode.2)thepythonvirtualmachine(pvm)thenexecuteTesthisbytecode、balancingeaseoputhswithporformance。

pythonisbothintersedand compiled.1)it'scompiledtobytecode forportabalityacrossplatforms.2)bytecodeisthenは解釈され、開発を許可します。

loopsareideal whenyouwhenyouknumberofiterationsinadvance、foreleloopsarebetterforsituationsは、loopsaremoreedilaConditionismetを使用します

henthenumber ofiterationsisknown advanceの場合、dopendonacondition.1)forloopsareideal foriterating over for -for -for -saredaverseversives likelistorarrays.2)whileopsaresupasiable forsaresutable forscenarioswheretheloopcontinupcontinuspificcond


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

ドリームウィーバー CS6
ビジュアル Web 開発ツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

Dreamweaver Mac版
ビジュアル Web 開発ツール
