Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 more flexible also by allowing for part time work,or ride sharing, so also ask for the number of days worked per week. Your program should ask for these 3 things, and then calculate the emissions for the entireyear. Use a global constant to hold the number of pounds emission per gallon of gasoline (noother variables should be global). Be sure to use all the correct comments for your program.Follow the steps used to develop the Python program:

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions