検索
ホームページバックエンド開発Python チュートリアルDay-Dictionary、ネストされたループを使用した文字の頻度

Day-Dictionary, Frequency of character using nested loops

辞書-{}

辞書は、キーと値のペアでデータ値を保存するために使用されます。
辞書は、順序付けされ、変更可能で、重複を許可しないコレクションです。
辞書では、各要素にはインデックス作成ではなく、キーによってアクセスできます。
辞書にキーが含まれていない場合、出力は「KeyError」になります。

例:

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}

student = {"name":"raja", "class":5}

print(thisdict)
print(student)
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}
{'name': 'raja', 'class': 5}

1.文字列内の各文字の頻度を求める

s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name print j>





<pre class="brush:php;toolbar:false">l 1
a 2
k 1
s 1
h 2
m 1
i 2
p 1
r 1
t 1

2.文字は一度だけ出現しました

s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and print j>





<pre class="brush:php;toolbar:false">l 1
k 1
s 1
m 1
p 1
r 1
t 1

3.最も頻繁な手紙

s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and print j>





<pre class="brush:php;toolbar:false">a 2
h 2
i 2

4.繰り返されない最初の文字

s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and print break j>





<pre class="brush:php;toolbar:false">l 1

5.最初に繰り返された文字

s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and print break j>





<pre class="brush:php;toolbar:false">a 2

6.繰り返されない最後の文字

last = ' '
last_count = 0 
s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and last="key" last_count="count" j print>





<pre class="brush:php;toolbar:false">t 1

7.最後に繰り返された手紙

last = ' '
last_count = 0 
s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" count="1" i="j+1" if while name and last="key" last_count="count" j print>





<pre class="brush:php;toolbar:false">i 2

8.最も頻繁に使用される文字

s = 'lakshmipritha'
name = list(s)
j = 0 
last = ' '
last_count = 0 

while j<len key="name[j]" count="1" i="j+1" if while name and>last_count:
            last = key
            last_count = count
    j+=1

print(last, last_count)
</len>
a 2

9.母音の頻度 (a、e、i、o、u)

vowels = ['a','e','i','o','u']
last = ' '
last_count = 0 
s = 'lakshmipritha'
name = list(s)
j = 0 
while j<len key="name[j]" if in vowels: count="1" i="j+1" while name print j>





<pre class="brush:php;toolbar:false">a 2
i 2

以上がDay-Dictionary、ネストされたループを使用した文字の頻度の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
どのデータ型をPythonアレイに保存できますか?どのデータ型をPythonアレイに保存できますか?Apr 27, 2025 am 12:11 AM

Pythonlistscanstoreanydatatype,arraymodulearraysstoreonetype,andNumPyarraysarefornumericalcomputations.1)Listsareversatilebutlessmemory-efficient.2)Arraymodulearraysarememory-efficientforhomogeneousdata.3)NumPyarraysareoptimizedforperformanceinscient

Pythonアレイに間違ったデータ型の値を保存しようとするとどうなりますか?Pythonアレイに間違ったデータ型の値を保存しようとするとどうなりますか?Apr 27, 2025 am 12:10 AM

heouttemptemptostoreavure ofthewrongdatatypeinapythonarray、yure counteractypeerror.thisduetothearraymodule'sstricttypeeencultionyを使用します

Python Standard Libraryの一部はどれですか:リストまたは配列はどれですか?Python Standard Libraryの一部はどれですか:リストまたは配列はどれですか?Apr 27, 2025 am 12:03 AM

PythonListSarePartOfThestAndardarenot.liestareBuilting-in、versatile、forStoringCollectionsのpythonlistarepart。

スクリプトが間違ったPythonバージョンで実行されるかどうかを確認する必要がありますか?スクリプトが間違ったPythonバージョンで実行されるかどうかを確認する必要がありますか?Apr 27, 2025 am 12:01 AM

theScriptisrunningwithwrongthonversionduetorectRectDefaultEntertersettings.tofixthis:1)CheckthedededefaultHaulthonsionsingpython - versionorpython3-- version.2)usevirtualenvironmentsbycreatingonewiththon3.9-mvenvmyenv、andverixe

Pythonアレイで実行できる一般的な操作は何ですか?Pythonアレイで実行できる一般的な操作は何ですか?Apr 26, 2025 am 12:22 AM

PythonArraysSupportVariousoperations:1)SlicingExtractsSubsets、2)Appending/ExtendingAdddesements、3)inSertingSelementSatspecificpositions、4)remvingingDeletesements、5)sorting/verversingsorder、and6)listenionsionsionsionsionscreatenewlistsebasedexistin

一般的に使用されているnumpy配列はどのようなアプリケーションにありますか?一般的に使用されているnumpy配列はどのようなアプリケーションにありますか?Apr 26, 2025 am 12:13 AM

numpyarraysAressertialentionsionceivationsefirication-efficientnumericalcomputations andDatamanipulation.theyarecrucialindatascience、mashineelearning、物理学、エンジニアリング、および促進可能性への適用性、scaledatiencyを効率的に、forexample、infinancialanalyyy

Pythonのリスト上の配列を使用するのはいつですか?Pythonのリスト上の配列を使用するのはいつですか?Apr 26, 2025 am 12:12 AM

UseanArray.ArrayOverAlistinPythonは、Performance-criticalCode.1)homogeneousdata:araysavememorywithpedelements.2)Performance-criticalcode:Araysofterbetterbetterfornumerumerumericaleperations.3)interf

すべてのリスト操作は配列でサポートされていますか?なぜまたはなぜですか?すべてのリスト操作は配列でサポートされていますか?なぜまたはなぜですか?Apr 26, 2025 am 12:05 AM

いいえ、notallistoperationSaresuptedbyarrays、andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorintorintorinsertizizing、whosimpactsporformance.2)リスト

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

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

ホットツール

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません