-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculations.py
More file actions
31 lines (26 loc) · 1.17 KB
/
Copy pathcalculations.py
File metadata and controls
31 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from config import EMISSION_FACTORS, PER_CAPITA_EMISSIONS
def calculate_emissions(country, distance, electricity, waste, meals):
factors = EMISSION_FACTORS[country]
transportation = round(factors["Transportation"] * distance / 1000, 2)
electricity = round(factors["Electricity"] * electricity / 1000, 2)
waste = round(factors["Waste"] * waste / 1000, 2)
diet = round(factors["Diet"] * meals / 1000, 2)
total = round(transportation + electricity + waste + diet, 2)
return transportation, electricity, waste, diet, total
def calculate_rewards_and_challenges(transportation, electricity, waste, diet, total):
challenges = []
rewards = 0
badges = []
# Logic for challenges and rewards
if transportation > 2:
challenges.append("🚗 Reduce transportation emissions by carpooling.")
if electricity > 3:
challenges.append("💡 Use energy-efficient appliances.")
if waste > 1:
challenges.append("🚮 Recycle more.")
if diet > 4:
challenges.append("🍔 Reduce meat consumption.")
if total < 5:
rewards += 20
badges.append("Sustainability Master")
return challenges, rewards, badges