Question: Need this coded in python. Background An online magnet seller sells a particular magnet at a base price of $0.75 but offers bulk pricing depending
Need this coded in python.



Background An online magnet seller sells a particular magnet at a base price of $0.75 but offers bulk pricing depending on the quantity of magnets ordered, as follows: Quantity Price 0449 $0.75 50-99 $0.72 100-999 $0.70 1000+ $0.67 Write a script using the template below. Replace the comment in the template with a function called get_costo) that calculates the cost of an order of magnets using the pricing scheme in the table above. Your function should take a non- negative number of magnets (an integer) as its only argument. It should return (1) a float indicating the cost of the order in dollars. If the number of magnets is less than zero, your function should raise a ValueError. Your function should have a docstring that briefly states What the function does what argument(s) it requires what kind of value it returns and what this value means what error(s) it raises and what they mean The template code is designed to take one integer as a command-line argument. It validates this argument, converts it to an integer, invokes your function, and prints a string containing the value returned by your function. Template "... Calculate the price of an order of magnets according to a bulk pricing scheme." import sys # replace this comment with your implementation of the get_cost() function if 11 name main__": try: magnets = int(sys.argv[1]) except IndexError: sys.exit("this program expects a number of magnets as a command-line" argument") except ValueError: sys.exit("could not convert" + sys.argv[1] + " into an integer") print(get_cost(magnets)) Background In the previous exercise, you developed a script that calculates the cost of an order of magnets using a bulk pricing scheme. Now you will develop a Pytest test script to test your earlier script. Instructions Write a test script with at least four "happy path" test cases and at least four edge cases. Make it clear which test cases fall into which categories (for example, you might split them into separate functions, or you might include comments marking the start of each type of test case). You should create your test script in the same directory as your bulk pricing script. Have your test script import your get_cost() function. Run your test script using Pytest. If any tests fail, determine whether the failure is due to mistakes in the original script or the test script
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
