7.23 Clone of LAB: Driving costs - functions Driving is expensive. Write a program with a car's miles/gallon and gas dol

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

7.23 Clone of LAB: Driving costs - functions Driving is expensive. Write a program with a car's miles/gallon and gas dol

Post by answerhappygod »

7 23 Clone Of Lab Driving Costs Functions Driving Is Expensive Write A Program With A Car S Miles Gallon And Gas Dol 1
7 23 Clone Of Lab Driving Costs Functions Driving Is Expensive Write A Program With A Car S Miles Gallon And Gas Dol 1 (22.72 KiB) Viewed 45 times
7 23 Clone Of Lab Driving Costs Functions Driving Is Expensive Write A Program With A Car S Miles Gallon And Gas Dol 2
7 23 Clone Of Lab Driving Costs Functions Driving Is Expensive Write A Program With A Car S Miles Gallon And Gas Dol 2 (25.54 KiB) Viewed 45 times
7.23 Clone of LAB: Driving costs - functions Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating point value with two digits after the decimal point, which can be achieved as follows: print('(:.2f).format(your_value)) Ex If the input is: 20.0 3.1599 the output is 1.58 7.90 63.20 Your programymust define and call the following driving cost() function. Given input parameters driven miles, miles per gallon, and dollars per gallon, the function returns the dollar cost to drive those miles. Ex If the function is called with 50 20,0 3.1509 the function returns ******
Ex: If the function is called with: 50 20.0 3.1599) the function returns: 7.89975 def driving cost (driven miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. Note: This is a lab from a previous chapter that now requires the use of a function. LAB ACTIVITY main.py 1 def Drivingcost (drivenMiles, milesPerGallon, dollarsPerGallon): 2 return drivenMiles / milesPerGallon dollarsPerballon name 3 4 if 5 7.23.1: Clone of LAB. Driving costs-functions 9 10 0/10 Load default template. main milesPerGallon float (input()) dollarsPerGallon 6 float (input()) 7 print("%f %f %f %(float(Drivingcost (10,milesPerGallon, dollarsPerGallon)), float (Drivingcost (50, milesPergallon, dollars
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply