burning one gallon of gasoline in your car produces 19.4 pounds of CO2. Calculat
ID: 667311 • Letter: B
Question
burning one gallon of gasoline in your car produces 19.4 pounds of CO2. Calculate the amount of CO2 emitted during a year for the following vehicles, assuming they all travel 12,000 miles per year. The reported fuel efficiency numbers were extracted from the U.S Department of energy website and reflect the combined city and highway estimates.
2013 Smart Car ForTwo 36 mpg 2013 Honda Civic 32 mpg 2013 Honda Civic Hybrid 44 mpg 2013 Chevrolet Malibu 26 mpg 2013 Toyota Prius (hybrid) 50 mpg 2013 Toyota yaris 33 mpgExplanation / Answer
#integers x = 12 y = 3 print(x + y) #can't mix data types #print (12 + "hi") #gives 0 because the two variables are integers print(1 / 5) #gives the remainder print(1 % 5) #modulus operator is useful for hash operators. #convert 200 seconds to minutes and seconds # If you just do division only, you'll have a fractional number of minutes but you won't have minutes and seconds. To get seconds, you need to use the mod operator. minutes = 200/60 seconds = (200%60) #seconds = input("How many seconds? ") #seconds = raw_input("How many seconds? ") #seconds = int(raw_input("How many seconds? ")) print(seconds) print (str(minutes) + str(seconds)) print("minutes is", minutes, "seconds is", seconds) co2 = 19.4 mpg = 26 miles = 12000 #python executes things left to right. When the floating point number is moved to the front, we get the more accurate result. #because the result of 19.4/12000 is a float. The result of co2 * miles / mpg is a float. print("How much CO2?", miles / mpg * co2, " pounds.") print("How much Co2", co2 * miles / mpg, "pounds.") print("How much CO2?", float(miles) / mpg * co2, "pounds.") pounds = miles / mpg * co2 #string = "pounds %s" % pounds string = "pounds %.2f" % pounds #string = "pounds %.4f and miles %s" % (pounds, miles) #string = "pounds %.4f and miles %d" % (pounds, pounds) print(string) #strings and numbers are called "string literals". floats are called "floating point literals" co2 = 19.4 mpg = 26.0 miles = 12000 print("How much CO2?", miles / mpg * co2, " pounds.") print("How much Co2", co2 * miles / mpg, "pounds.") co2 = 19.4 mpg = 26.0 miles = input("How many miles? ") print("How much CO2?", miles / mpg * co2, " pounds.") print("How much Co2", co2 * miles / mpg, "pounds.")
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.