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 program must 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.
Use the following .py file to get started:
#variables
miles_per_gallon = float(input("Please enter the miles per
gallon: "))
dollars_per_gallon = float(input("PLease enter the cost per gallon:
"))
#calculations
dollars_20_miles = 20 * (1.0 / miles_per_gallon) *
dollars_per_gallon
dollars_75_miles = 75 * (1.0 / miles_per_gallon) *
dollars_per_gallon
dollars_500_miles = 500 * (1.0 / miles_per_gallon) *
dollars_per_gallon
print('{:.2f} {:.2f} {:.2f}'.format(dollars_20_miles, dollars_75_miles. dollars_500_miles))
In: Computer Science
|
Stdev |
Stock A |
Stock B |
Market |
|||
|
Stock A |
23.00% |
Stock A |
1.0 |
0.5 |
0.3 |
|
|
Stock B |
13.00% |
Stock B |
0.5 |
1.0 |
0.8 |
|
|
Market |
18.00% |
Market |
0.3 |
0.8 |
1.0 |
In: Finance
CODE IN PYTHON:
Your task is to write a simple program that would allow a user to compute the cost of a road trip with a car. User will enter the total distance to be traveled in miles along with the miles per gallon (MPG) information of the car he drives and the per gallon cost of gas. Using these 3 pieces of information you can compute the gas cost of the trip.
User will also enter the number of days it will take to complete the trip. For each night (day-1 nights), user will need a hotel. We will ask for the number of stars for the hotel the user wants to stay. 5 star hotel costs $250 per night. 4 star hotel costs $180 per night. 3 star hotel costs $120 per night, 2 star hotel costs $100 per night and finally 1 star hotel costs $50 per night. Using the hotel costs and the number of nights users will need to stay at a hotel, you can compute the hotel cost of the trip.
Please note that 5 star and 4 star hotels give 10% discount if the user will be staying more than 2 nights -- (these are chain hotels, so even if you are staying at different locations discount apply).
We should also account for the cost of meals. This depends on the type of hotel the user is staying. In general, we take 20% of hotel cost as the meal cost (after 10% hotel discount if applicable).
Example Run #1
Distance: 350
MPG : 15
Gas Price: 3.79
Days Traveling : 3
Hotel Stars (1-5) : 3
Your total cost is $376.43333333333334
Example Run #2
Distance: 400
MPG : 20
Gas Price: 2.99
Days Traveling: 1
Hotel Stars (1-5): 5
Your total cost is $59.800000000000004.
Example Run #3
Distance: 150 MPG : 25 Gas Price: 1.99 Days Traveling : 2 Hotel Stars (1-5): 5 Your total cost is $311.94.
In: Computer Science
Please add formula answer included
In: Accounting
Please answer/discuss the following questions?
Assume you are the RM for a newly opened theme park in a major southwestern city. Your guests will consist primarily of families visiting the park, as well as schoolchildren on field trips and church youth groups. Yours is the only such park within 150 miles. Identify at least five non-cost factors you would want to consider as you determine the prices that will be charged for the menu items you will sell. Explain why you selected each factor chosen.
In: Economics
Plot the absorption mode signal of a Lorentzian line as a function of frequency for w=100 hz, and three values T2 equal to 1.0 sec, 0.3 sec, and 1.0 sec. How is the full width of the peak related to the value of T2?
In: Chemistry
What is the expected output from the following program (3 answers)
______ ______namespace std; double insurance(int); void main() { int j; ______ mileage; ______ monthly_rent; for (j=______ j<4; j++) { mileage=1000*j; monthly_rent= 0.3*mileage + insurance(mileage); printf("Monthly rent for %4d.2f is : $ ______ . \n", mileage, monthly_rent); } } double insurance(int miles) { double mileage_charge; if (miles<=1000) { mileage_charge=100.0; }___ if ((miles>1000) && (miles<=2000)) { mileage_charge=150.0; }; ___ (miles>2000) { mileage_charge=200.0; }; return(mileage_charge);
In: Computer Science
Construct a histogram of your empirical data using eight bars and then five bars. For consistency's sake, for eight bars use the class width of 0.125. So, your first bar will be 0.000-0.124, your next bar will be 0.125 - 0.249, etc. For five bars, use the class width of 0.2. So, your first bar will be 0.00-0.19, your next bar will be 0.2-0.39, etc. Upload both pictures of your histograms. ***Below are my 50 random numbers. What do I need to show? I am confused on what exactly I need to show. Can you help me on these?
0.9 1.0 0.7 0.0 0.8
0.0 0.8 0.2 0.0 1.0
0.5 0.2 0.5 0.4 0.0
0.8 0.1 0.4 0.2 1.0
0.1 0.1 0.9 0.7 0.1
0.9 1.0 0.9 0.2 0.4
0.0 1.0 0.5 0.9 0.4
0.9 0.0 0.0 1.0 0.3
0.4 0.8 0.9 0.6 0.5
0.4 0.5 0.3 0.7 1.0
In: Math
You are the designer for a public address (PA) system to be installed for a new hotel. The hotel shall have 15 storeys, 230 rooms, one recreational floor, one car park floor, two restaurants, and two banquet rooms.
(a) One of the banquet rooms has dimensions 45 m (width) x 35 m (length) x 5.5 m (height). If ceiling-mounted loudspeakers of 110° coverage angle is to be installed, calculate the number of speakers required for the room. State clearly ALL your assumptions in the calculations. Draw a simple layout plan to show the locations of the loudspeakers.
In: Electrical Engineering
1. Write the half reactions that occur at the anode and cathode in these electrochemical cells. Annotate which half reaction occurs at the anode and the cathode.
2. Write the overall balance reaction for the following electrochemical cells.
Ag(s), Ag(NO3)2 (1.0 M) || Cu (s), CuCl2 (1.0M)
Zn(s), Zn(NO3)2 (1.0M) || Ni (s), Ni(NO3)2 (1.0M)
Zn(s), Zn(NO3)2 (0.3 M) || Cu(s), CuCl2 (0.5M)
Ag(s), Ag(NO3)2 (0.3 M) || Cu(s), CuCl2 (0.5 M)
Ag(s), Ag(NO3)2 (0.3 M) || Ni(s), Ni(NO3)2 (0.5 M)
Cu(s), CuCl2 (.001 M) || Cu(s), CuCl2 (1.0 M)
Thank you!!!
In: Chemistry