Question

In: Computer Science

Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the...

Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the items and calculates the tax due and the total due. The number of inputs is not known. You can assume that the input is always valid. (i.e no negative numbers or string like "cat"). Use a loop that takes the prices of items as parameters that are floats, counts the number of items, and sums them to find the total. You must also use a function that takes the total of the items as input and returns the tax on the amount of the cart. Use a tax rate of 6.25%. The formula for the tax is total*tax_rate. The total due is total_of_items + tax_rate. DO NOT USE LIST. sys.argv only

Input in the command prompt: python script2-4.py 0.95 0.95 5.95 12.95 2.45 1.45

The output for the input above should be exactly the same as the following:

Number of items: 6

Total of items: $24.70

Tax amount: $ 1.54

Total due: $26.24

Solutions

Expert Solution

Code is Given Below:

====================

#creating list to hold items
items=[]
while(True):
#asking user to enter data
i=float(input("Enter Price: "))
items.append(i)
option=input("Wants to enter more (Y/N): ")
if option=='Y' or option=='y':
continue
else:
break
#calculating tax
def taxCalc(total):
return total*0.0625
count=0
sum=0
#finding total
for item in items:
sum=sum+item
count=count+1
#calculating tax
tax=taxCalc(sum)
total_due=sum+tax
#printing result
print("Number of items:",count)
print("Total of items: ${:.2f}".format(sum))
print("Tax amount: ${:.2f}".format(tax))
print("Total due: ${:.2f}".format(total_due))
  

Output:

==========

Code Snapshot:

==================


Related Solutions

Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the...
Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the items and calculates the tax due and the total due. The number of inputs is not known. You can assume that the input is always valid. (i.e no negative numbers or string like "cat"). Use a loop that takes the prices of items as parameters that are floats, counts the number of items, and sums them to find the total. You must also use...
Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the...
Write a script called script2-4.py that takes a person's delivery order as inputs, totals all the items and calculates the tax due and the total due. The number of inputs is not known. You can assume that the input is always valid. (i.e no negative numbers or string like "cat"). Use a loop that takes the prices of items as parameters that are floats, counts the number of items, and sums them to find the total. You must also use...
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers...
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers from the user until they enter a 0 and computes the product of all these numbers and outputs it. Hint: use the example from the slides where we compute the sum of a list of numbers, but initialize the variable holding the product to 1 instead of 0. print("Enter n") n = int(input()) min = n while n != 0: if n < min:...
Write a function that takes two integer inputs and returns the sum of all even numbers...
Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers between these inputs .In main function, the program will asks the user to enter two integer numbers and then passes them to these two functions and display the result of each of them
Deliverables There is one deliverable for this assignment hw4.py Make sure the script obeys all the...
Deliverables There is one deliverable for this assignment hw4.py Make sure the script obeys all the rules in the Script Requirements page. Specification The file has entries like the following Barnstable,Barnstable,1 Bourne,Barnstable,5 Brewster,Barnstable,9 ... This script should create a dictionary where the county is the key and then total number of cases for the country is the value. The script should print the name of the county with the highest number of cases along with the total cases. The script...
Deliverables There is one deliverable for this assignment hw6.py Make sure the script obeys all the...
Deliverables There is one deliverable for this assignment hw6.py Make sure the script obeys all the rules in the Script Requirements page. Specification The script must have 3 functions: get_args create_python_file print_directory get_args This function must have the following header: def get_args(arg_number): This function takes as its parameter an integer. The function should look at the number of command line arguments that the script gets when it is run. If the number of command line arguments is less than the...
Deliverables There is one deliverable for this assignment hw1.py Make sure the script obeys all the...
Deliverables There is one deliverable for this assignment hw1.py Make sure the script obeys all the rules in the Script Requirements page. What is Special About This Assignment This homework assignment is going to be different from the other assignments. You will have to do very little coding for this assignment. Instead, I will supply you with a function that will test regular expressions using regular expressions contained in the following variables: regex_1 regex_2 regex_3 regex_4 regex_5 regex_6 regex_7 regex_8...
Write a shell script (to run on the Bourne shell) called cp2.sh to copy all the...
Write a shell script (to run on the Bourne shell) called cp2.sh to copy all the files from two named directories into a new third directory. Timestamps must be preserved while copying files from one directory into another. Task Requirements Three directory names must be supplied as arguments to your script when it is executed by the user. In the beginning of your script you need to check that the first two directory names provided (e.g. dir1 and dir2) exist...
Write a program, Lab02_Q4.py, that inputs a string from the user, and creates a new string...
Write a program, Lab02_Q4.py, that inputs a string from the user, and creates a new string that deletes each non-alphanumeric character in the original string. You should solve this problem in 2 ways, first use a for loop that iterates through each character in the string, the second should use a while loop that iterates through a range. Keep spaces in the new string also. Hint: You can invoke the isalnum() function on a character, and it will return True...
Write a method called isMatch that takes a string of parentheses and check if all parentheses...
Write a method called isMatch that takes a string of parentheses and check if all parentheses match correctly. The parameter string might consist of other characters. Ignore other characters, just check the () {} [] public static boolean isMatch(String expressionLine); Use a JCF ArrayDeque or LinkedList as a stack to store all open or left parentheses. Use following main method to check your method. public static void main(String[] args) { String[] expression = new String[]{"{5*(x+2)+(y-1);}", "32*(20+(x[i]*3)-1", "((){([][])})", "({}((0))", "{([]})", "{}())",...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT