Question
Calculate CO2 emissions in a year based on the distance to work and the miles per gallonefficiency of the vehicle. You want to make it
1. Create a function called yearly_miles_driven that receives variables that hold thedistance to work and the days worked each week. This function should calculate andreturn the miles driven per year.
2. Create a function called gallons_used_per_year that receives the miles driven each yearand the miles per gallon for the vehicle. This function should calculate and return thegallons of gas used each year.
3. Create a function called emission_per_year that receives the gallons of gas used peryear and returns the pounds of CO2 emitted each year.
4. Create a main() function that is used to gather user input, call your functions and display properly formatted output (i.e. the output of your program should be on two lines in a simple table format
#create and initialize variables and constants
#input
#process
#output
Finally, to calculate the CO2 emissions from a gallon of fuel, the carbon emissions are multiplied by theratio of the molecular weight of CO2 (m.w. 44) to the molecular weight of carbon (m.w.12): 44/12. CO2 emissions from a gallon of gasoline = 2,421 grams x 0.99 x (44/12) = 8,788
grams = 8.8 kg/gallon = 19.4 pounds/gallon
CO2 emissions from a gallon of diesel = 2,778 grams x 0.99 x (44/12) = 10,084
grams = 10.1 kg/gallon = 22.2 pounds/gallon
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started