In: Computer Science
Monthly Sales Tax
A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 5 percent and the county sales tax rate is 2.5 percent. Write a Python program with function(s) that asks the user to enter the total sales for the month. Make sure that you do not allow user to enter negative values for the total sales (that is validate with a loop). From the entered total sales amount, your program should calculate and display the following:
The amount of state sales tax
The total sales tax (county plus state)
Falling Distance
When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:
[Math Processing Error]distance=12gt2The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling.
Write a function named falling_distance (in Python) that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Write a Python program (main function) that calls the falling_distance function in a loop that passes the values 1 through 10 as arguments and displays the return value for each iteration.
Monthly Sales Tax:
Program:
# defining function to calculate state sales tax
def state_sales_tax(n):
# returning 5% sales tax
return n*0.05
# defining function to calculate country sales tax
def country_sales_tax(n):
# returning 2.5 % tax
return n*0.025
# defining function to return total sales tax
def total_sales_tax(n):
# returning states tax + country tax
return state_sales_tax(n) + country_sales_tax(n)
# defining main function
if __name__ == '__main__':
# asking for input and validating input using while loop
total_sales = float(input("Enter total sales for the the month: "))
# validating user input with loop for negative values
while total_sales < 0:
print("Invalid input!")
total_sales = float(input("Enter total sales for the the month: "))
# printing values
print('The amount of county sales tax: ', country_sales_tax(total_sales))
print('The amount of state sales tax', state_sales_tax(total_sales))
print('The total sales tax (county plus state)', total_sales_tax(total_sales))
Code Snippet:

Output #1:

Output #2:

Output #3:

Falling Distance:
Program:
# defining falling_distance function
def falling_distance(t):
# variable g with 9.8 as value
g = 9.8
# computing value of d and rounding it
d = round((1/2)*g*(t*t), 2)
# returning computed value of d
return d
# defining main function
if __name__ == '__main__':
# loop for 1 to 10
for i in range(1, 11):
# print returned value
print(falling_distance(i))
Code Snippet:

Output Snippet:

I hope you got the provided solution.
Thank You.