Question

In: Computer Science

The school bookstore wants you to write a Python script to calculate the point of sale...

The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements: Write a Python script (with meaningful comments) that has a main() function. Have that main() function call another function to display a welcome to the customer. In the main() function, ask the user how many gift cards they would like and how many books they have picked out. Function requirements are as follows: You must write a function to calculate the cost for the gift card(s), a function to calculate the cost of the books, and a function that takes the subtotal applies the 8% (multiply by 0.08) sales tax then returns the total to main(). Display the subtotal in main(). Round all dollar amounts to 2 decimal places (note: python will truncate unnecessary 0s without formatting so do not worry if output only has the tenths place). Only function definitions and the call to main() can be at 1st level indentation. For a challenge, see if you can make your main function contain less lines that the other functions. Examples: Welcome to the bookstore! Gift cards are $25.00 each Each book costs $5. How many gift cards do you want? 1 How many books do you have? 2 Your subtotal is $35 Your total is $37.8 and Welcome to the bookstore! Gift cards are $25.00 each Each book costs $5. How many gift cards do you want? 2 How many books do you have? 4 Your subtotal is $70 Your total is $75.6

Solutions

Expert Solution

I have given the code for the above problem and also I attached output screens,make sure you run in the PYTHON-3 and

if you want you can remove the "if __name__ == "__main__": function and write it as main() function and call it.

And Iam sure you know python check if any indentation error occurs depends on which compiler you use

Python code

#welcome function to say welcome to the customer and tells the giftcards and bookcost details
def welcome():
    print("Welcome to the bookstore! Gift cards are $25.00 each Each book costs $5 ")

#functionnto calculate the cost of the giftcards
def costforthegiftcards(giftcards):
    giftcardcost=25 
    totalgiftcardscost=giftcards*giftcardcost
    return totalgiftcardscost

#funtion to calculate the cost of the books     
def costofthebooks(books):
    bookcost=5 
    totalbookscost=books*bookcost
    return totalbookscost

#function to calculate the subtotal and total of giftcards and books     
def calculatesubtotal(giftreturn,bookreturn):
    l=[]
    subtotal=giftreturn+bookreturn
    total=subtotal+subtotal*0.08
    l.append(subtotal)
    l.append(total)
    return l


#our main function 
if __name__ == "__main__":
    #calling the welcome function 
    welcome()
    
    #asking the customer the number of giftcards he want
    giftcards=int(input("Please enter How many gift cards do you want? "))
    
    #asking the customer the number of books he want
    books=int(input("Please enter How many books do you have? "))
    
    #calculating the giftcardscost
    giftreturn=costforthegiftcards(giftcards)
    
    #calculating the bookscost
    bookreturn=costofthebooks(books)
    
    #calculating the subtotal and total using the above  functions
    values=calculatesubtotal(giftreturn,bookreturn)
    
    #printing the results 
    print("Your subtotal is "+"$"+str(values[0])+" Your total is "+"$"+str(values[1]))

    

Output Execution screens with code

Note-We are using lists for the simplicity of the process


Related Solutions

The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
How do I write a script for this in python in REPL or atom, NOT python...
How do I write a script for this in python in REPL or atom, NOT python shell Consider the following simple “community” in Python . . . triangle = [ ["top", [0, 1]], ["bottom-left", [0, 0]], ["bottom-right", [2, 0]], ] This is the calling of function. >>> nearestneighbor([0, 0.6], triangle, myeuclidean) 'top' The new point is (0, 0.6) and the distance function is Euclidean. Now let’s confirm this result . . . >>> myeuclidean([0, 0.6], [0, 1]) 0.4 >>> myeuclidean([0,...
Write a Python script that: Ask the customer for their current bank balance. One thing you...
Write a Python script that: Ask the customer for their current bank balance. One thing you dont have to worry about is whether or not the user enters a negative or positive amount.. Ask the customer if they wish to deposit ('d') or withdraw ('w') from that amount. Ask them to enter the amount of money they are either depositing or withdrawing. This has to be a positive numeric value. If it is negative, you should print an error message...
Summary Lewis wants you to write another script that shows a table of events at the...
Summary Lewis wants you to write another script that shows a table of events at the Lyman Hall Theater over the next two weeks from the current date. He has already created three arrays for use with the script: The eventDates array containing a list of dates and times at which theater events are scheduled. The eventDescriptions array containing the description of those events. The eventPrices array containing the admission prices of those events. Lewis has already written the page...
Write a Python script that takes an input image and output's the name of the dominant...
Write a Python script that takes an input image and output's the name of the dominant color in that image(i.e. red, green, blue).  
PYTHON: Write a script that imports the functions in the module below and uses all of...
PYTHON: Write a script that imports the functions in the module below and uses all of the functions. import math def _main():     print("#" * 28, "\n", "Testing...1, 2, 3...testing!\n", "#" * 28, "\n", sep="")     f = -200     print("{:.2f} F is {:.2f} C".format(f, f2c(f)))     f = 125     print("{:.2f} F is {:.2f} C".format(f, f2c(f)))     c = 0     print("{:.2f} C is {:.2f} F".format(c, c2f(c)))     c = -200     print("{:.2f} C is {:.2f} F".format(c, c2f(c))) def f2c(temp):     #Converts Fahrenheit tempature to Celcius     if temp <...
Write a Flask app in which a Python script prompts the user to enter a string...
Write a Flask app in which a Python script prompts the user to enter a string and then that string, as entered, gets displayed on an otherwise blank HTML file, called output.html. Show the Python/Flask code and the html code of the output.html file, one below the other as part of your answer.
Using Python write an application that will calculate a loan payment. To complete this, you are...
Using Python write an application that will calculate a loan payment. To complete this, you are required to write 2 functions, LoanPayment and InterestOnlyLoanPayment, as well as a test application that calls each of the functions to get the payment amount based on parameters supplied to the functions. The test application should output both the loan payment and the interest-only loan payment based on input values from the user. The LoanPayment function is defined as follows: Payment = Loan amount...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT