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. DO NOT USE LIST.DO NOT USE LIST.DO NOT USE LIST.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 and output

Code for copying

n=input()
orders=n.split(" ")
count=0
sum_items=0
for i in orders:
sum_items+=float(i)
count+=1
tax_amount=sum_items*(0.0625)
total_due=sum_items+tax_amount
print("Number of items: {}".format(count))
print("Total of items: ${:.2f}".format(sum_items))
print("Tax amount: ${:.2f}".format(tax_amount))
print("Total due: ${:.2f}".format(total_due))

Code snippet

n=input()
orders=n.split(" ")
count=0
sum_items=0
for i in orders:
    sum_items+=float(i)
    count+=1 
tax_amount=sum_items*(0.0625)
total_due=sum_items+tax_amount 
print("Number of items: {}".format(count))
print("Total of items: ${:.2f}".format(sum_items))
print("Tax amount: ${:.2f}".format(tax_amount))
print("Total due: ${:.2f}".format(total_due))


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...
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...
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))", "{([]})", "{}())",...
1. Write a program in C++ that takes as inputs a positiveinteger n and a...
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?2.  Write a program in C++ that takes as input a positive integer n and computes the following productsum...
Linux Script Convert String (Part 1) Write a simple shell script that takes a permission string...
Linux Script Convert String (Part 1) Write a simple shell script that takes a permission string expressed as -rwxrwxrwx and prints out whether or not theobject is a directory, file or link. The string is read in from standard input. Convert String (Part 2) Modify the script so its able to print out the octal permission which the string represents along with the file type. This is in addition to part 1. Convert String (Part 3) For the script in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT