素数:
1 で割り切れる数とそれ自体を素数と呼びます。(例-->3,5,7)
1) 素数を見つけるかどうか:
no = int(input("Enter no. ")) div = 2 while div<no: if no print prime break div else:> <p>出力:<br> </p> <pre class="brush:php;toolbar:false">1)Enter no. 5 Prime 2)Enter no. 6 Not Prime
2) 入力された数値を反転し、反転した数値が素数かどうかを調べます。
def reverse_a_no(no): reverse = 0 while no>0: rem = no%10 reverse = (reverse*10) + rem no//=10 #no=no//10 return reverse no = int(input("Enter no. ")) reversed_no = reverse_a_no(no) #31 71 print(reversed_no) def find_prime(no): div = 2 while div<no: if no return false break div else: true result1="find_prime(no)" result2="find_prime(reversed_no)" result2: print number emirp> <p>出力:<br> </p> <pre class="brush:php;toolbar:false">1)Enter no. 15 51 EMIRP number 2)Enter no. 14 41 not EMIRP number
完全数
完全な数とは、割り切れる数の合計がその数字に等しいことを意味します。(例-->6 は 1,2,3 で割り切れ、1 2 3=6)
def find_perfect(no): total = 0 div = 1 while div<no: if no total="total" div else: no: return true false no. result="find_perfect(no)" true: print number perfect> <p>出力:<br> </p> <pre class="brush:php;toolbar:false">Enter no. 6 Perfect Number
平方根:
入力数値の 2 乗とその平方根数値の桁の合計を求めます。
def square(no): return no**2 no=int(input("Enter the number:")) result=square(no) def sum_of_digits(num): sum=0 while num>0: sum=sum+num%10 num=num//10 return sum if result <p>出力:<br> </p> <pre class="brush:php;toolbar:false">Enter the number:4 7
上記の例では、指定された入力番号は 4 です。
--> 4 の平方根は 4x4=16
--> その平方数の桁の合計 1 6=7.
タスク -1 **
**自動同型数
数字の四角形が同じ数字で終わるかどうかを確認します。
例: 5 → オートモーフィック (5²=25)、6 → オートモーフィック (6²=36)、7 → オートモーフィックではありません。
def square(no): return no**2 no=int(input("Enter the number:")) result=square(no) print(result) while result>0: rem=result%10 if rem==no: print("Automorphic number") break else: print("Not Automorphic number") break
出力:
1)Enter the number:5 25 Automorphic number 2)Enter the number:4 16 Not Automorphic number
タスク:2
フィボナッチ数列
指定された数値までのフィボナッチ数列を生成します。
例: 入力: 10 → 出力: 0、1、1、2、3、5、8。
no = int(input("Enter the number of required sequence: ")) first_num,sec_num =0 ,1 while first_num <p>出力:<br> </p> <pre class="brush:php;toolbar:false">Enter the number of required sequence: 10 0 1 1 2 3 5 8
以上がPython Day - ループ - 演習とタスクの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

slicingapythonlistisdoneusingtheyntaxlist [start:stop:step] .hore'showitworks:1)startisthe indexofthefirstelementtoinclude.2)spotisthe indexofthefirmenttoeexclude.3)staptistheincrementbetbetinelements

numpyallows forvariousoperationsonarrays:1)basicarithmeticlikeaddition、減算、乗算、および分割; 2)AdvancedperationssuchasmatrixMultiplication;

Arraysinpython、特にnumpyandpandas、aresentialfordataanalysis、offeringspeedandeficiency.1)numpyarraysenable numpyarraysenable handling forlaredatasents andcomplexoperationslikemoverages.2)Pandasextendsnumpy'scapabivitieswithdataframesfortruc

listsandnumpyarraysinpythonhavedifferentmemoryfootprints:listsaremoreflexiblellessmemory-efficient、whileenumpyarraysaraysareoptimizedfornumericaldata.1)listsstorereferencesto objects、with whowedaround64byteson64-bitedatigu

toensurepythonscriptsbehaveCorrectlyAcrossDevelosment、staging、and Production、usetheseStrategies:1)環境variablesforsimplestetings、2)configurationfilesforcomplexsetups、and3)dynamicloadingforadaptability.eachtododododododofersuniquebentandrequiresca

Pythonリストスライスの基本的な構文はリストです[start:stop:step]。 1.STARTは最初の要素インデックス、2。ストップは除外された最初の要素インデックスであり、3.ステップは要素間のステップサイズを決定します。スライスは、データを抽出するためだけでなく、リストを変更および反転させるためにも使用されます。

ListSoutPerformArraysIn:1)ダイナミシジョンアンドフレーケンティオン/削除、2)ストーリングヘテロゼンダタ、および3)メモリ効率の装飾、ButmayhaveslightPerformancostsinceNASOPERATIONS。

toconvertapythonarraytoalist、usetheList()constructororageneratorexpression.1)importhearraymoduleandcreateanarray.2)useList(arr)または[xforxinarr] toconvertoalistは、largedatatessを変えることを伴うものです。


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

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

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

メモ帳++7.3.1
使いやすく無料のコードエディター

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









