自己作一個盈餘成長率【g】的計算機
由於太懶惰了,想用現學現賣的python來試著做看看----盈餘成長率【g】的計算機
程式碼:
#盈餘成長率g計算機
stock_id=int(input("請輸入股票代號:"))
roe=float(input("請輸入"+str(stock_id)+"的ROE:"))
eps=float(input("請輸入"+str(stock_id)+"的EPS:"))
dividend=float(input("請輸入"+str(stock_id)+"的股利:"))
cash_interestRate=dividend/eps
#現金配息率=股利/eps
E_growth_rate=roe*(1-cash_interestRate)
#盈餘成長率=roe*(1-現金配息率)=roe*再投資率(RI)
print(str(stock_id)+"現金配息率是"+str(cash_interestRate*100)+"%")
print(str(stock_id)+"的盈餘成長率是"+str(E_growth_rate)+"%")
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
到公開資訊觀測站抓台泥營收
程式碼:
import urllib.request
page=urllib.request.urlopen("http://mopsov.tse.com.tw/t21/sii/t21sc03
_100_1.html")
text=page.read().decode("ISO-8859-1")
target=text.find('¥xªd')
start_of_revenue=target+33
end_of_revenue=start_of_revenue+10
revenue=text[start_of_revenue:end_of_revenue]
print('台泥'+"的營收是"+str(revenue)+"千元")
Posted by silentpower at 痞客邦 PIXNET 留言(1) 引用(0) 人氣()
截取 http://beans.itcarlow.ie/prices.html 的網頁資訊
程式碼:
import urllib.request
page=urllib.request.urlopen("http://beans.itcarlow.ie/prices.html")
text=page.read().decode("utf8")
where=text.find(">$")
start_of_price=where+1
end_of_price=start_of_price+4
price=text[start_of_price:end_of_price]
print("今天咖啡豆的價錢是"+price+"元")
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
The Zen of Python (英文原文版)
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
程式碼:
#if_excise
#if & elif & else的練習
i=int(input("請輸入一個小於14的正整數:"))
if i>13:
print("你輸入的數字太大了")
elif i<0:
print("你輸入的數字小於零")
else:
if i>7:
print("你輸入的數字比7大")
elif i==7:
print("你輸入的數字剛好等於7")
else:
print("你輸入的數字比7小")
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
ex:
令L = [1,2,3,4,5,6,7,8,9,10],請把其中的偶數找出來
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()
ex1:
程式碼:
#list _excise
ABC_list=["A","B","C"]
for each_item in ABC_list:
print(each_item)
Posted by silentpower at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()