Python my economyのソースを表示
←
Python my economy
ナビゲーションに移動
検索に移動
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、以下のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
== 概要 == cgi動作用Webアプリケーションです。<br> 死荷重や需要P供給P等を調べます.<br> 当初Python初学期間の為、文法等が汚いです == 使用例 == [https://miniapp.sufee.net/economy.cgi] === cgi === <syntaxhighlight lang="python3"> #!/usr/bin/python3 import cgi print("Content-type: text/html; charset=utf-8") print() print('<!DOCTYPE html>') def send_print(message): global propertyType if propertyType['Fixed'] != '1': print(f'<p>{message}</p>') def tax_math(res=[],sha=[],p=0,x=0,taxF=0): print('不要ならゼロ') shareP = 0 while True: try: tax = float(taxF) if tax == 0: print('終了') return None try: tax = 1 + (tax * 0.01) except: tax = 1 share = tax * sha[0] shareP = tax * sha[1] break except: print('有効な値を入力してください。') price = (share + -res[0])/(-shareP + res[1]) send_print(f'D,Sは{price}です') resbusiness = res[0] + (res[1]*price) if resbusiness < 0: resbusiness = (res[1]*price) + res[0] send_print(f'需要Pは{resbusiness}です') shabusiness = share + (shareP*price) if shabusiness < 0: shabusiness = (share*price) + share send_print(f'供給Pは{shabusiness}です') if shabusiness == resbusiness: business = (shabusiness + resbusiness) / 2 send_print(f'焦点からPは{business}です。') tate = 0 D = res[0] + (res[1] * x) S = sha[0] + (sha[1] * x) ST = share + (shareP * price) if shareP > 1 or shareP < -1: tateS = (sha[0] / sha[1]) + (sha[1] * price) tate = tateS - sha[0] if tate < 0: tate *= -1 else: tateS = sha[0] + price tate = tateS - sha[0] if tate < 0: tate *= -1 if shabusiness != resbusiness: send_print(f'1/2 * ({tate}) * {price}') ProducerSurplus = 0.5 * (tate) * price send_print(f'生産者余剰は{ProducerSurplus}です') else: send_print(f'1/2 * {(tate)} * {price}') ProducerSurplus = 0.5 * (tate) * price send_print(f'生産者余剰は{ProducerSurplus}です') if res[1] > 1 or res[1] < -1: tate = res[0] / res[1] if tate < 0: tate *= -1 else: tate = res[0] if shabusiness != resbusiness: tate = price - D send_print(f'1/2 * (({tate} - {tateS} ) + {ST} - {tateS}) * {price}') ConsumerSurplus = 0.5 * ((tate - tateS)+(ST - tateS)) * price send_print(f'消費者余剰は{ConsumerSurplus}です') else: send_print(f'1/2 * (({tate} - {tateS} ) + {ST} - {tateS}) * {price}') ConsumerSurplus = 0.5 * ((tate - tateS)+(ST - tateS)) * price send_print(f'消費者余剰は{ConsumerSurplus}です') TotalSurplus = ConsumerSurplus + ProducerSurplus send_print(f'総余剰は{TotalSurplus}です') deadLoad = 0.5 * (ST - tateS) * (x - price) if deadLoad != 0: print(f'よって死荷重は{deadLoad}') else: print(f'よって死荷重はありませんでした。') propertyType = {'tax':'0','Fixed':'0'} form = cgi.FieldStorage() html = f''' <head> <link rel="icon" href="/img/icon/meta_web/1101.ico"> <link rel="apple-touch-icon" sizes="128x128" href="/img/icon/meta_web/1101.ico"> <meta name="application-name" content="sufee.net"/> <meta name="msapplication-square70x70logo" content="/img/icon/meta_web/1102.ico"/> <meta name="msapplication-square150x150logo" content="/img/icon/meta_web/1102.ico"/> <meta name="msapplication-square310x310logo" content="/img/icon/meta_web/1101.ico"/> <meta name="msapplication-wide310x150logo" content="/img/icon/meta_web/1101.ico"/> <title>需要供給計算 - sufee 計算</title> <meta charset="utf-8"> <meta http-equiv="content-language" content="ja"> <meta http-equiv="content-type" content="text/html:charset=utf-8"> <meta name="author" content="yuki"> <link rel="canonical" href="/"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> </head> ''' print(html) print('<body>') print('<center>') try: html = f''' <h1>需要供給計算機</h1> <form method="POST"> D = <input type="number" name="request" value="{str(form.getvalue("request")).replace('None','0')}"> + <input type="number" name="requestP" value="{str(form.getvalue("requestP")).replace('None','0')}"> P<br> S = <input type="number" name="share" value="{str(form.getvalue("share")).replace('None','0')}"> + <input type="number" name="shareP" value="{str(form.getvalue("shareP")).replace('None','0')}"> P<br> 固定価格 <input type="number" name="price" value="{str(form.getvalue("price")).replace('None','0')}"><br> 従量税 <input type="number" name="SpecificDuty" value="{str(form.getvalue("SpecificDuty")).replace('None','0')}"><br> 従価税 <input type="number" name="tax" value="{str(form.getvalue("tax")).replace('None','0')}"><br> <br> <input type="submit" value="計算開始"> </form> ''' except: html = ''' <form method="POST"> 需要曲線 D = <input type="number" name="request" value="0"> + <input type="number" name="requestP" value="0">P 供給曲線 S = <input type="number" name="share" value="0"> + <input type="number" name="shareP" value="0">P 固定価格<input type="number" name="price" value="0"><br> 従量税<input type="number" name="SpecificDuty" value="0"><br> 従価税<input type="number" name="tax" value="0"><br> <input type="submit" value="計算開始"> </form> <br> ''' print(html) print('<div style="margin-top:30px;margin-bottom:30px;padding-top:30px;width: 68%;border-style: solid;border-color: rgb(250, 216, 221);border-radius: 15px;">') if form.getvalue("request") and form.getvalue("requestP") and form.getvalue("share") and form.getvalue("shareP"): print('<h1 style="color:red;">結果</h1>') temp = None request = int(form.getvalue("request")) requestP = int(form.getvalue("requestP")) share = int(form.getvalue("share")) shareP = int(form.getvalue("shareP")) if not(form.getvalue("SpecificDuty") == '0' and form.getvalue("tax") == '0'): propertyType['tax'] = '1' SpecificDuty = float(form.getvalue("SpecificDuty")) share = share + SpecificDuty print(f'S = {shareP} + {share - SpecificDuty}') if form.getvalue("price") != '0': propertyType['Fixed'] = '1' price = (share + -request)/(-shareP + requestP) send_print(f'価格は{price}です') while True: resbusiness = request + (requestP*price) if resbusiness < 0: resbusiness = (requestP*price) + request send_print(f'需要取引量は{resbusiness}です') shabusiness = share + (shareP*price) if shabusiness < 0: shabusiness = (shareP*price) + share send_print(f'供給取引量は{shabusiness}です') if shabusiness == resbusiness: business = (shabusiness + resbusiness) / 2 send_print(f'均衡取引量は{business}です。') tate = 0 D = request + (requestP * price) S = share + (shareP * price) #消費者余剰 if requestP > 1 or requestP < -1: tate = request / requestP if tate < 0: tate *= -1 else: tate = request if shabusiness != resbusiness: tate = tate - price send_print(f'1/2 * ({tate}) * {D}') ConsumerSurplus = 0.5 * (tate) * D send_print(f'消費者余剰は{ConsumerSurplus}です') else: send_print(f'1/2 * {(tate-price)} * {D}') ConsumerSurplus = 0.5 * (tate-price) * D send_print(f'消費者余剰は{ConsumerSurplus}です') #生産者余剰 if shareP > 1 or shareP < -1: tate = share / shareP if tate < 0: tate *= -1 else: tate = share if shabusiness != resbusiness: tate = price - S send_print(f'1/2 * ({tate}+{price}) * {S}') ProducerSurplus = 0.5 * (tate+price) * S send_print(f'生産者余剰は{ProducerSurplus}です') else: send_print(f'1/2 * {(price-tate)} * {S}') ProducerSurplus = 0.5 * (price-tate) * S send_print(f'生産者余剰は{ProducerSurplus}です') TotalSurplus = ConsumerSurplus + ProducerSurplus send_print(f'総余剰は{TotalSurplus}です') if temp: send_print('-------------') send_print(f'固定なし総余剰は{temp}です') send_print(f'固定あり総余剰は{TotalSurplus}です') deadLoad = temp - TotalSurplus print(f'よって死荷重は{deadLoad}') if propertyType['Fixed'] == '1': temp = TotalSurplus price = int(form.getvalue('price')) propertyType['Fixed'] = '0' continue elif propertyType['tax'] == '1': tax_math(res=[request,requestP],sha=[share,shareP],p=shabusiness,x=price,taxF=form.getvalue("tax")) else: break break print('</div>') print('</body>') print('</html>') #else: #send_print(f'需要取引量が{resbusiness}、供給取引量が{shabusiness}であるため接点が見つかりませんでした。') </syntaxhighlight>
Python my economy
に戻る。
案内メニュー
個人用ツール
アカウント作成
ログイン
名前空間
ページ
議論
日本語
表示
閲覧
ソースを閲覧
履歴表示
その他
検索
案内
メインページ
最近の更新
おまかせ表示
MediaWikiについてのヘルプ
コード系
Program
PHP
Java
Python
Swift
JavaScript
HTML
CSS
C言語
MySQL
サーバー系
Apache2
OS系
Debian
kail
アプリケーション系
Xcode
Android Studio
計算系
ファイル系
速度系
メモ・業務
My命名規則
ツール
リンク元
関連ページの更新状況
特別ページ
ページ情報
編集
左メニュー
動画挿入について
動画・音声を追加する
JavaScriptを埋め込む
ページにリダイレクトを指定する