Python Forum
pls help with this assignment. basic into to python class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pls help with this assignment. basic into to python class
#1
working on visual studio code, python 3.8.6
i want to learn so feel free to just leave advice and no solution.
1.This is a simplified gas station app. The app menu allows a customer to fill gas, and a manager to get sales information, reset totals, and change gas prices. (Ideally, manager access should be separate and secured by password; but we are not doing that in this app)

Functions:
fill() : Prompts the customer to select the grade of fuel: Regular, Extra, or Premium. (Prices 3.70$, 3.90$, 4.10$ per gallon: these prices are displayed before asking the customer to choose the grade of fuel.)
When the customer makes the selection, the selected grade and its price are displayed to the customer.
Next, the customer enters the number of gallons to be filled. .Price of the gas order is computed using a function. Afterwards, fill() displays the price. (If the user enters 0 for gallons, the app displays ‘Operation Cancelled’)


there is more to the problem after this but this is what im stuck on.
-the part im getting most trouble with is having to use another function to compute the price.
i have tried creating a loop but im stuck and dont even know what to ask for help
Reply
#2
Please show what you've done so far.
Reply
#3
(Nov-20-2020, 02:24 AM)valerie_thomas Wrote: -the part im getting most trouble with is having to use another function to compute the price.
Don't make it more difficult than it is. Sure you know how to calculate the order price: order_price = price * gallons. So:
def compute_order_price(price, gallons):
    return price * gallons

# Now test it:
order_price = compute_order_price(3.90, 9.5)
print("total order price is: ", order_price)
Output:
total order price is: 37.05
Now show us how you incorporate this in yourfill() function.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic python Natters10 3 3,102 Nov-29-2020, 07:04 AM
Last Post: Love2code
  Assignment of non-existing class variable is accepted - Why? DrZ 6 4,289 Jul-13-2020, 03:53 PM
Last Post: deanhystad
  Help with basic python AaronG123 4 2,271 Nov-14-2019, 02:57 PM
Last Post: AaronG123
  Converting c++ class to python class panoss 12 11,875 Jul-23-2017, 01:16 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020