Last active
January 12, 2025 00:34
-
-
Save roflsunriz/bd7b243db5a6b7dffecc416c4cf4bd46 to your computer and use it in GitHub Desktop.
DaikinACCostCalculator : エアコン電気代計算プログラム ダイキンEシリーズエアコンの地域ごとモデルごとのランニングコストを計算します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DaikinACCostCalculator: | |
| def __init__(self): | |
| # 既存の電力会社データを継承 | |
| self.electricity_companies = { | |
| '東京電力': { | |
| 'base_fee': 935.25, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 29.80}, | |
| {'limit': 300, 'rate': 36.40}, | |
| {'limit': float('inf'), 'rate': 40.49} | |
| ] | |
| }, | |
| '九州電力': { | |
| 'base_fee': 948.72, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 18.37}, | |
| {'limit': 300, 'rate': 23.97}, | |
| {'limit': float('inf'), 'rate': 26.97} | |
| ] | |
| }, | |
| '関西電力': { | |
| 'base_fee': 0, | |
| 'rates': [ | |
| {'limit': float('inf'), 'rate': 22.48} | |
| ] | |
| }, | |
| '中部電力': { | |
| 'base_fee': 990.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 21.04}, | |
| {'limit': 300, 'rate': 25.78}, | |
| {'limit': float('inf'), 'rate': 28.29} | |
| ] | |
| }, | |
| '東北電力': { | |
| 'base_fee': 990.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 20.32}, | |
| {'limit': 300, 'rate': 25.80}, | |
| {'limit': float('inf'), 'rate': 29.29} | |
| ] | |
| }, | |
| '北海道電力': { | |
| 'base_fee': 1045.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 22.32}, | |
| {'limit': 280, 'rate': 28.30}, | |
| {'limit': float('inf'), 'rate': 32.30} | |
| ] | |
| }, | |
| '中国電力': { | |
| 'base_fee': 990.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 19.66}, | |
| {'limit': 300, 'rate': 25.15}, | |
| {'limit': float('inf'), 'rate': 28.52} | |
| ] | |
| }, | |
| '四国電力': { | |
| 'base_fee': 990.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 20.32}, | |
| {'limit': 300, 'rate': 25.80}, | |
| {'limit': float('inf'), 'rate': 29.29} | |
| ] | |
| }, | |
| '北陸電力': { | |
| 'base_fee': 990.00, | |
| 'rates': [ | |
| {'limit': 120, 'rate': 17.46}, | |
| {'limit': 300, 'rate': 22.94}, | |
| {'limit': float('inf'), 'rate': 26.31} | |
| ] | |
| } | |
| } | |
| # ダイキンEシリーズの仕様データ | |
| self.ac_models = { | |
| 'S22YTES': {'cooling_capacity': 2.2, 'power': 0.485, 'applicable_area': [6, 8, 10]}, | |
| 'S25YTES': {'cooling_capacity': 2.5, 'power': 0.575, 'applicable_area': [8, 10, 12]}, | |
| 'S28YTES': {'cooling_capacity': 2.8, 'power': 0.675, 'applicable_area': [10, 12, 14]}, | |
| 'S36YTES': {'cooling_capacity': 3.6, 'power': 0.975, 'applicable_area': [12, 14, 16]}, | |
| 'S40YTES': {'cooling_capacity': 4.0, 'power': 1.265, 'applicable_area': [14, 16, 18]}, | |
| 'S56YTES': {'cooling_capacity': 5.6, 'power': 1.785, 'applicable_area': [18, 20]} | |
| } | |
| # 部屋の広さ選択肢 | |
| self.room_sizes = [6, 8, 10, 12, 14, 16, 18, 20] | |
| def set_electricity_company(self, company_name): | |
| if company_name in self.electricity_companies: | |
| self.selected_company = company_name | |
| return True | |
| return False | |
| def calculate_electricity_cost(self, kwh_usage): | |
| if not hasattr(self, 'selected_company'): | |
| raise ValueError("電力会社が設定されていないのじゃ!") | |
| company_data = self.electricity_companies[self.selected_company] | |
| total_cost = company_data['base_fee'] # 基本料金 | |
| remaining_kwh = kwh_usage | |
| # 段階別料金の計算 | |
| for i, rate_info in enumerate(company_data['rates']): | |
| if remaining_kwh <= 0: | |
| break | |
| usage_in_stage = min(remaining_kwh, rate_info['limit']) | |
| if i > 0: # 2段階目以降の場合 | |
| usage_in_stage = min(remaining_kwh, | |
| rate_info['limit'] - company_data['rates'][i-1]['limit']) | |
| cost_in_stage = usage_in_stage * rate_info['rate'] | |
| total_cost += cost_in_stage | |
| remaining_kwh -= usage_in_stage | |
| return round(total_cost) | |
| def calculate_monthly_cost(self, model, hours_per_day, days_per_month=30): | |
| if not hasattr(self, 'selected_company'): | |
| raise ValueError("電力会社が設定されていないのじゃ!") | |
| ac_data = self.ac_models[model] | |
| monthly_kwh = ac_data['power'] * hours_per_day * days_per_month | |
| return self.calculate_electricity_cost(monthly_kwh) | |
| def get_recommended_models(self, room_size): | |
| return [model for model, data in self.ac_models.items() | |
| if room_size in data['applicable_area']] | |
| def main(): | |
| print("ダイキンEシリーズエアコン 冷房費計算プログラムへようこそなのじゃ!٩(。•ω•。)و\n") | |
| calculator = DaikinACCostCalculator() | |
| # 地域選択 | |
| print("=== お住まいの地域を選んでください ===") | |
| regions = { | |
| '1': {'area': '北海道', 'electric': '北海道電力'}, | |
| '2': {'area': '東北', 'electric': '東北電力'}, | |
| '3': {'area': '関東', 'electric': '東京電力'}, | |
| '4': {'area': '中部', 'electric': '中部電力'}, | |
| '5': {'area': '関西', 'electric': '関西電力'}, | |
| '6': {'area': '中国', 'electric': '中国電力'}, | |
| '7': {'area': '四国', 'electric': '四国電力'}, | |
| '8': {'area': '九州', 'electric': '九州電力'} | |
| } | |
| # 地域選択の処理 | |
| for key, value in regions.items(): | |
| print(f"{key}: {value['area']}") | |
| while True: | |
| region_choice = input("\n番号を入力してください: ") | |
| if region_choice in regions: | |
| selected_region = regions[region_choice] | |
| calculator.set_electricity_company(selected_region['electric']) | |
| break | |
| print("正しい番号を入力するのじゃ!") | |
| # 部屋の広さ選択 | |
| print("\n=== 部屋の広さを選んでください ===") | |
| for size in calculator.room_sizes: | |
| print(f"{size}畳") | |
| # 部屋の広さ選択の処理 | |
| while True: | |
| try: | |
| selected_size = int(input("\n畳数を入力してください: ")) | |
| if selected_size in calculator.room_sizes: | |
| break | |
| print(f"対応している畳数から選ぶのじゃ!: {calculator.room_sizes}") | |
| except ValueError: | |
| print("数字を入力するのじゃ!") | |
| # モデル選択 | |
| print("\n=== エアコンモデル一覧 ===") | |
| all_models = list(calculator.ac_models.items()) | |
| for i, (model, data) in enumerate(all_models, 1): | |
| applicable_area = f"{min(data['applicable_area'])}~{max(data['applicable_area'])}畳" | |
| print(f"{i}: {model} (冷房能力: {data['cooling_capacity']}kW, 消費電力: {data['power']}kW, 適用畳数: {applicable_area})") | |
| while True: | |
| try: | |
| model_choice = int(input("\nモデルの番号を選んでください: ")) | |
| if 1 <= model_choice <= len(all_models): | |
| selected_model = all_models[model_choice - 1][0] | |
| selected_data = calculator.ac_models[selected_model] | |
| # 選択した畳数が適用範囲外の場合は警告を表示 | |
| if selected_size not in selected_data['applicable_area']: | |
| print(f"\n⚠️ 注意: 選択したモデル {selected_model} は {selected_size}畳の部屋には推奨されないサイズなのじゃ!") | |
| confirm = input("それでも続けますか? (y/n): ") | |
| if confirm.lower() != 'y': | |
| continue | |
| break | |
| print(f"1から{len(all_models)}までの番号を入力するのじゃ!") | |
| except ValueError: | |
| print("数字を入力するのじゃ!") | |
| # 使用時間設定 | |
| print("\n=== 1日の使用時間を入力してください ===") | |
| while True: | |
| try: | |
| hours = float(input("時間(デフォルト: 8時間): ") or "8") | |
| if 0 < hours <= 24: | |
| break | |
| print("0より大きく24以下の数値を入力するのじゃ!") | |
| except ValueError: | |
| print("正しい数値を入力するのじゃ!") | |
| # 結果表示 | |
| monthly_cost = calculator.calculate_monthly_cost(selected_model, hours) | |
| print(f"\n=== 計算結果 ===") | |
| print(f"地域: {selected_region['area']}") | |
| print(f"部屋の広さ: {selected_size}畳") | |
| print(f"選択モデル: {selected_model}") | |
| print(f"1日の使用時間: {hours}時間") | |
| print(f"1ヶ月の電気代目安: {monthly_cost:,}円") | |
| input("Enterキーを押して終了するのじゃ!") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方:
1.プログラムを起動する。
2.地域を選ぶ。
3.部屋の広さを選ぶ。
4.モデルを選ぶ。
5.稼働時間を入力する。
6.計算結果を見る。