Eile Edit View History Bookmarks Tools Help Student Access t

Eile Edit View History Bookmarks Tools Help Student Access to e-Ca X SaksiaURI :csc 110 Spri.. X Issues in Biotechnology X Votch 24 xovier ws St Joh... X e a iphone text for windows For each ot tho rollowing exercises, be suro to test your answers by using Python on your own computer. Submit a soparato py file tor each or the questions below. Sample Code 1.conoidor tho following variabl assignments: csc Links Croate a Python file with theso assignments as the first Ines of code. Next, include a singlo Python statoment to compute the value of z defined by the following equation: 2 c Gradebook E 2a -3b 42 University Course Finally, include a statement to print the value of Site Info Submit the Python code in the py 2. White a set of Python commands that wil oompute sales tax for purchases made in August, Your code should do the following: The program prompts the user to enter the value of the sale with the following statement: nter the value of ho dollars August 2016: The sale value should be stored in a variable oftype float Compute based on 8% of the sale Print the resulting sales tax in tho following format for August 2013 The output of the program should look something like tho following Python 3 5.2:4def 2c2901 6 2016, 12:47:25) CGcc 4.2 Inc. build 5666) (dot for more formation Type credits\" opyrig RESTART Users/ dipi ppo/Documents/csc onework/hw-solutions-fa 016/hw1-2 Enter the value of the company\'s sales in dollars in August 2016: S45000 The t for the nonth of August is s 2700.0 RESTART: /Users/Udipi solutions-fa 016/hw1-2 /csc of the company August 2016: SS6aee The tax for th h of Augu S 3360.0 RESTART: /Users/Udipi onework how-solutions-fa 016/h 1-2 s/esc of the company August 2016: S12340 The tax for th h of Augu S 740.4 Tost your program with at least tho val roonshatabo Submit the py file with yo Program O X

Solution

1) We need to import math library. The assignments (a=5,...) are integer type and we may get the result in floating point. Therefore, we need to type cast the numerator with float while dividing. Otherwise, we will get wrong values.

File Name: calculateZ.py

import math
a=5
b=2
c=3

z=(float(2*a-3*b)/8)+((float(42)/(math.pow(a,2)-math.pow(b,2)))*(float(2)/a+float(c)/6)/b)

print(\"Value of z = %.4f\" %z)

Output (print to four decimal precision using (%.4f)):

Value of z = 1.4000

----------------------------------------------------------------------------------------------------------

2)

File Name: calculateSalesTax.py

sales=float(input(\"Enter the value of the company\'s sales in dollars in August 2016: $\"))
salesTax=(float(6)/100)*sales
print(\"The tax for the month of August is $ %.1f\" %salesTax)

Output (print to one decimal precision using (%.1f)):

$ python calculateSalesTax.py

Enter the value of the company\'s sales in dollars in August 2016: $45000
The tax for the month of August is $ 2700.0

$ python calculateSalesTax.py

Enter the value of the company\'s sales in dollars in August 2016: $56000
The tax for the month of August is $ 3360.0

$ python calculateSalesTax.py
Enter the value of the company\'s sales in dollars in August 2016: $12340
The tax for the month of August is $ 740.4

 Eile Edit View History Bookmarks Tools Help Student Access to e-Ca X SaksiaURI :csc 110 Spri.. X Issues in Biotechnology X Votch 24 xovier ws St Joh... X e a i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site