In: Computer Science
Complete the following in syntactically correct Python code.
Write a program, using a for loop, that calculates the amount of money a person would earn over a period of time if his or her salary is 1 penny for the first day, 2 pennies for the second day, 4 pennies for the third day, and continues to double each day.
1. The program should ask the user for the number of days the employee worked.
2. Display a table showing the salary for each day.
3. Display the total salary at the end of the period.
4. The output should be displayed in dollar amounts, not the number of pennies.
5. Format your output to include a $ sign and 2 decimal places.
6. Be sure to comment appropriately.
CODE
SNAPSHOT:
OUTPUT
SNAPSHOT:
CODE:
days = int(input("Enter number of days: ")) # taking input
total_sum = 0.0
print("Day Salary")
for i in range(0,days):
salary = 2**i
salary = salary/100 # calculation of per day salary
total_sum +=salary # Keep on adding the salary
print("{} {}$".format(i+1,salary)) # print in a formatted way
print("\nTotal Salary is: {:.2f}".format(total_sum)) #print the total salary
Please comment in case of doubts or queries.
It would be really helpful if you could upvote :)