財(cái)務(wù)大數(shù)據(jù)基礎(chǔ)(第二版)課件 項(xiàng)目五 Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)_第1頁
財(cái)務(wù)大數(shù)據(jù)基礎(chǔ)(第二版)課件 項(xiàng)目五 Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)_第2頁
財(cái)務(wù)大數(shù)據(jù)基礎(chǔ)(第二版)課件 項(xiàng)目五 Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)_第3頁
財(cái)務(wù)大數(shù)據(jù)基礎(chǔ)(第二版)課件 項(xiàng)目五 Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)_第4頁
財(cái)務(wù)大數(shù)據(jù)基礎(chǔ)(第二版)課件 項(xiàng)目五 Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)_第5頁
已閱讀5頁,還剩40頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

項(xiàng)目五Python循環(huán)結(jié)構(gòu)程序設(shè)計(jì)目標(biāo)理解循環(huán)結(jié)構(gòu)理解for循環(huán)和while循環(huán)的用法了解continue和break的用法任務(wù)一存儲(chǔ)2020年到2023年的相關(guān)財(cái)報(bào)數(shù)據(jù)相關(guān)知識各年數(shù)據(jù)的存儲(chǔ)全部數(shù)據(jù)的存儲(chǔ)年

度2020年2021年2022年2023年凈利潤165010221.56202662270.20244060018.62-7834747.02期初凈資產(chǎn)2761772535.392885521135.423312422711.803560111655.87期末凈資產(chǎn)2885521135.423312422711.803560111655.873429031128.43各年數(shù)據(jù)的存儲(chǔ)每年數(shù)據(jù)如何存儲(chǔ)?年

度2020年2021年2022年2023年凈利潤165010221.56202662270.20244060018.62-7834747.02期初凈資產(chǎn)2761772535.392885521135.423312422711.803560111655.87期末凈資產(chǎn)2885521135.423312422711.803560111655.873429031128.43各年數(shù)據(jù)的存儲(chǔ)每年數(shù)據(jù)如何存儲(chǔ)?年

度2020年凈利潤165010221.56期初凈資產(chǎn)2761772535.39期末凈資產(chǎn)2885521135.42各年數(shù)據(jù)的存儲(chǔ)每年數(shù)據(jù)存入一個(gè)字典年

度2020年2021年2022年2023年凈利潤165010221.56202662270.20244060018.62-7834747.02期初凈資產(chǎn)2761772535.392885521135.423312422711.803560111655.87期末凈資產(chǎn)2885521135.423312422711.803560111655.873429031128.43cSoftDict1cSoftDict2cSoftDict3cSoftDict4["profit"]["beginAsset"]["endAsset"]["period"]各年數(shù)據(jù)的存儲(chǔ)每年數(shù)據(jù)存入一個(gè)字典

全部數(shù)據(jù)的存儲(chǔ)用一個(gè)列表存儲(chǔ)四個(gè)字典任務(wù)二使用for循環(huán)計(jì)算各年凈資產(chǎn)收益率相關(guān)知識for循環(huán)range函數(shù)for循環(huán)控制語句塊的重復(fù)執(zhí)行for和in都是關(guān)鍵字迭代器是Python語言中的重要機(jī)制之一for循環(huán)變量in迭代器:

語句塊

循環(huán)的控制結(jié)構(gòu),它控制for中語句塊的執(zhí)行次數(shù)循環(huán)體此處為縮進(jìn),縮進(jìn)量通常為4個(gè)字符迭代器是一個(gè)值序列,或值集合迭代器中的值的個(gè)數(shù)就是for循環(huán)的次數(shù)for循環(huán)循環(huán)次數(shù)i值循環(huán)體10i的值為021i的值為132i的值為243i的值為3示例for循環(huán)循環(huán)次數(shù)i值循環(huán)體110i=10213i=13316i=16417i=17示例for循環(huán)循環(huán)次數(shù)item值循環(huán)體1’a’item=a2’b’item=b3’abc’item=abc4100item=100示例range()函數(shù)產(chǎn)生指定范圍的一系列值常作為for循環(huán)的迭代器range(n)range(m,n)range(m,n,d)省略m和d,m=0,d=1序列:0,1,2,3,…,n-1,即從0至n(不包括n)n≤0的時(shí)候序列為空省略d,d=1序列:m,m+1,m+2,…,n-1,即從m至n(不包括n)m≥n時(shí)序列為空序列:m,m+d,m+2d,…,即從m開始,依次按步長值d遞增(若d為負(fù)則遞減),直至那個(gè)最接近但不包括n的等差值結(jié)束for循環(huán)示例一cSoftList1[3]cSoftList1[2]cSoftList1[1]年

度2020年凈利潤165010221.56期初凈資產(chǎn)2761772535.39期末凈資產(chǎn)2885521135.42cSoftList1[0]cSoftList10,1,2,32,31,3for循環(huán)示例二["period"]2020年["period"]2021年["profit"]165010221.56["profit"]202662270.20["beginAsset"]2761772535.39["beginAsset"]2885521135.42["endAsset"]2885521135.42["endAsset"]3312422711.80cSoftList2[1]cSoftList2[0]cSoftList20,1使用循環(huán)從列表cSoftList中提取數(shù)據(jù)"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue0,1,2,3使用循環(huán)從列表cSoftList中提取數(shù)據(jù)程序流程圖使用循環(huán)從列表cSoftList中提取數(shù)據(jù)"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue2,30,2使用循環(huán)從列表cSoftList中提取年度數(shù)據(jù)"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue0,1,2,3cSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]cSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]使用循環(huán)提取2023年度的財(cái)報(bào)數(shù)據(jù)"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvaluecSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]使用循環(huán)提取2023年度的財(cái)報(bào)數(shù)據(jù)程序流程圖cSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]計(jì)算每年的凈資產(chǎn)收益率"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue

計(jì)算2023年的凈資產(chǎn)收益率cSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]

計(jì)算公式:"period"2023年"profit"-7834747.02"beginAsset"3560111655.87"endAsset"3429031128.43cSoftList[3]keyvalue計(jì)算每年的凈資產(chǎn)收益率"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[0]cSoftList[1]cSoftList[2]cSoftList[3]計(jì)算每年的凈資產(chǎn)收益率"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue更新后的cSoftList任務(wù)三使用for循環(huán)比較凈資產(chǎn)收益率的大小相關(guān)知識continue語句break語句continue語句在未執(zhí)行完當(dāng)前循環(huán)的情況下,提前結(jié)束本次循環(huán),轉(zhuǎn)去進(jìn)行下一次新的循環(huán)continuerange(4):迭代對象range(0,4)list(range(4))[0,1,2,3]break語句結(jié)束當(dāng)前循環(huán),然后跳轉(zhuǎn)到循環(huán)后的下一條語句繼續(xù)執(zhí)行break輸出凈資產(chǎn)收益率超過5%的年度"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvaluecSoftList[0][“ROE”]>=0.05cSoftList[1][“ROE”]>=0.05cSoftList[2][“ROE”]>=0.05cSoftList[3][“ROE”]>=0.05使用continue控制for循環(huán)"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvaluecSoftList[0][“ROE”]<0.05cSoftList[1][“ROE”]<0.05cSoftList[2][“ROE”]<0.05cSoftList[3][“ROE”]<0.05使用continue控制for循環(huán)程序流程圖輸出第一個(gè)凈資產(chǎn)收益率超過5%的年度及凈資產(chǎn)收益率"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvaluecSoftList[0][“ROE”]>=0.05cSoftList[1][“ROE”]>=0.05cSoftList[2][“ROE”]>=0.05cSoftList[3][“ROE”]>=0.05輸出第一個(gè)凈資產(chǎn)收益率超過5%的年度及凈資產(chǎn)收益率程序流程圖任務(wù)四使用while循環(huán)比較相鄰年度凈資產(chǎn)收益率的變化相關(guān)知識while循環(huán)while循環(huán)的注意事項(xiàng)while循環(huán)控制語句塊的重復(fù)執(zhí)行條件為真時(shí)執(zhí)行語句塊

語句塊執(zhí)行結(jié)束再去判斷while條件

直到條件表達(dá)式值為假時(shí)結(jié)束循環(huán)while

條件表達(dá)式:

語句塊循環(huán)的控制結(jié)構(gòu),控制循環(huán)是否運(yùn)行循環(huán)體此處為縮進(jìn),縮進(jìn)量通常為4個(gè)字符條件表達(dá)式的值:真值或假值while循環(huán)示例cSoftList1[0]2020年cSoftList1[1]165010221.56cSoftList1[2]2761772535.39cSoftList1[3]2885521135.42cSoftList1循環(huán)條件判斷次數(shù)i值循環(huán)條件是否運(yùn)行循環(huán)print(cSoftList1[i])i=i+1100<4為真是cSoftList1[0]i=1211<4為真是cSoftList1[1]i=2322<4為真是cSoftList1[2]i=3433<4為真是cSoftList1[3]i=4544<4為假否

比較相鄰年度凈資產(chǎn)收益率的變化"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalueprePeriod=cSoftList[0]["period"]preROE=cSoftList[0]["ROE"]period=cSoftList[1]["period"]roe=cSoftList[1]["ROE"]prePeriod=cSoftList[1]["period"]preROE=cSoftList[1]["ROE"]period=cSoftList[2]["period"]roe=cSoftList[2]["ROE"]prePeriod=cSoftList[2]["period"]preROE=cSoftList[2]["ROE"]period=cSoftList[3]["period"]roe=cSoftList[3]["ROE"]比較相鄰年度凈資產(chǎn)收益率的變化"period"2020年"period"2021年"period"2022年"period"2023年"profit"165010221.56"profit"202662270.20"profit"244060018.62"profit"-7834747.02"beginAsset"2761772535.39"beginAsset"2885521135.42"beginAsset"3312422711.80"beginAsset"3560111655.87"endAsset"2885521135.42"endAsset"3312422711.80"endAsset"3560111655.87"endAsset"3429031128.43“ROE”0.0584386898“ROE”0.0653966138“ROE”0.0710247503“ROE”-0.002241977cSoftList[1]cSoftList[0]cSoftListcSoftList[3]cSoftList[2]keyvaluekeyvaluekeyvaluekeyvalue2020年2021年2021年比較相鄰年度凈資產(chǎn)收益率的變化

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論