In: Computer Science
The first assignment involves writing a Python program to
compute the weekly pay for a salesman. Your program should prompt
the user for the number of hours worked for that week and the
weekly sales. Your program should compute the total pay as the sum
of the pay based on the number of hours worked times the hourly
rate plus the commission. You should choose a value for the hourly
pay. The commission should be computed as a percentage of the
weekly sales. You should choose a value for the percentage. Your
program should output the pay based on the hours worked, the
commission and the total pay for the week.
Your program should include the pseudocode, used to come up with
the program statements, in the comments. Document the values you
chose for the hourly rate and commission percentage in your
comments as well.
You are to submit your Python program as a text file (.txt) file.
In addition, you are also to submit a test report in a Word
document or a .pdf file. 15% of your grade will be based on whether
the comments in your program include the pseudocode and define the
values of your constants, 70% on whether your program executes
correctly on all test cases and 15% on the completeness of your
test report.
Answer:
Here is the python code as per your requirement
Raw code:
#taking hours as input from the user
hours=int(input("Number of hours: "))
#taking weekly sales as input from user in float
weeklySales=float(input("Weekly Sales: "))
#let the hourly rate be 40 change it according to ur wish
hourlyRate=40
#let the commission percentage is 15 change it according to ur wish
commissionPercentage=15
#calculate the commision earned
weeklyCommission=(commissionPercentage/weeklySales)*100
#calculate the hourly pay
hourlyPay=hourlyRate*40
#calculating total pay by adding hourly rate earned and weekly commission
totalSales=hourlyPay+weeklyCommission
#printing the mto user
print("Pay for working hours: {}".format(hourlyPay))
print("Commission pay: {}".format(weeklyCommission))
print("Totla pay: {}".format(totalSales))
Editor:
output:
Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.
"Please refer to the screenshot of the code to understand the indentation of the code".
Thank you! Do upvote.