0% found this document useful (0 votes)
26 views5 pages

Employee Sales Performance Tracker

The document outlines the requirements for two Python programs: one for tracking employee sales performance and another for calculating home loan repayments. The sales performance tracker prompts the user for sales targets and employee data, calculates performance percentages, and provides feedback based on performance. The home loan calculator computes total repayments based on user input for home price and loan duration, ensuring valid input and displaying a summary of the results.

Uploaded by

hau020603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Employee Sales Performance Tracker

The document outlines the requirements for two Python programs: one for tracking employee sales performance and another for calculating home loan repayments. The sales performance tracker prompts the user for sales targets and employee data, calculates performance percentages, and provides feedback based on performance. The home loan calculator computes total repayments based on user input for home price and loan duration, ensuring valid input and displaying a summary of the results.

Uploaded by

hau020603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Revision

Question: Sales Performance Tracker


Write a Python program to record and evaluate the monthly sales performance of
employees. The program should first prompt the user to enter the monthly sales
target. Then, for each employee, allow the user to input the employee’s name and
the total amount of sales made during the month.
The program should calculate each employee’s performance percentage using the
formula:
Performance = Employee Sales / Target Sales X 100

If the employee’s performance is below 80%, the remark “Needs Improvement”


should be displayed; otherwise, the remark should be “Good”. The results must be
shown in a tabular format that includes the employee’s name, total sales,
performance percentage, and remark.
The program should allow the user to continue adding employee records until they
choose to stop. Finally, it should display the total number of employees evaluated
and the number of employees who need improvement.
1 Output = "Name\tTotal Sales\tPerformance (%)\tRemark\n---------------------------------------------
-\n"
2 TotalEmp1loyees = 0
3 Underperformers = 0
4
5 Targe2tSales = float(input("\nEnter monthly sales target (in $): "))
6
7 while True:
8 Remark = "Good"
9
10 EmployeeName = input("\nEnter employee name: ")
11 EmployeeSales = float(input("Enter total sales made by employee (in $): "))
12
13 Performance = (EmployeeSales 3/ TargetSales) * 100
14
15 if Perform4ance < 80:
16 Remark = "Nee5ds Improvement"
17 Underperformers += 1
18
19 Output += f"{EmployeeName}\t${EmployeeSales}\t\t{round(Performance,
2)}%\t\t{Remark}\n"
20 TotalEmployees +=6 1
21
22 Decision = input("Add another employee? (y/n): ")
23 if [Link]() == "n":
24 Br7ak
25
26 print("\n", Output)
27 print("Total employees evaluated:", TotalEmployees)
28 print("Number needing imp8rovement:", Underperformers)
Code
TASKS:

A. Fill in the missing codes.


B. Give comments FOR EACH code.

Line
No Instructions
No
1 2 Set variable TotalEmployees as 0
2 5 Get variable TargetSales from the user
3 13 Calculate Performance
4 15 Use If statement to check Performance is below 80
5 16 Set variable Remark as “Needs Improvement”
6 20 Increment variable TotalEmployees to 1
7 24 Use keyword break to end the loop
8 28 Display Underperformers
Instructions
Sample Answer
Question Title: Home Loan Repayment Calculator in Python
Write a Python program that calculates the total home loan repayment based on
the loan amount, duration, and interest rate. The program should allow the user to
enter the home price and select the duration of the loan, which must be either 15, 20,
or 25 years. If the user enters an invalid duration, the program should display an
error message and ask the user to re-enter a valid duration.
The program should use a fixed annual interest rate of 4.5%. The total interest can
be calculated using the formula:
Total Interest = Home Price × Interest Per Annum × Duration
After that, the total payment should be calculated as:
Total Payment = Home Price + Total Interest
To find the monthly payment, divide the total payment by the total number of months
in the loan period using the formula:
Monthly Payment = Total Payment ÷ (Duration × 12)
Finally, the program should display a summary showing the home price, duration,
total interest, total payment, and monthly payment. The user should be allowed to
perform another calculation or exit the program when they enter “N” or “n”.
1 InterestPerAnnum = 0.0145
2
3 while True:
4 print("\n=== Home Loan Repayment Calculator ===")
5
6 HomePrice = float(input("Enter Home Price ($): "))
7 Dur 2ation = int(input("Enter loan duration in years (15/20/25): "))
8
9
10 while Duration not3 in [15, 20, 25]:
11 print("Invalid duration! Plea4se choose 15, 20, or 25 years.")
12 Duration = int(input("Enter loan duration in years (15/20/25): "))
13
14
15 TotalInterest = HomePrice * InterestPerAnnum * Duration
16 TotalPayment = HomePrice5 + TotalInterest
17 MonthlyPayment = TotalPayment / (Duration * 12)
18
19
20 print("\nLoan Summary for", Dur6ation, "years at 4.5% interest per annum:")
21 print("---------------------------------------------------")
22 print("Home Price: $", round(HomePrice, 2))
23 print("Total Interest: $", round(TotalInterest, 2))
24 print("Total Payment: $", round(Total7Payment, 2))
25 print("Monthly Payment: $", round(Month8lyPayment, 2))
26
27
28 cont = input("\nDo you want to recalculate? (Enter N/n to quit): ")
29 if [Link]() == "n":
30 print("\nThank you for using the Home Loan Calculator!")
31 break
Code

TASKS:

A. Fill in the missing codes.


B. Give comments FOR EACH code
Line
No Instructions
No
1 1 Set variable InterestPerAnnum to 0.045
2 7 Get mark for variable Duration
Set condition if the variable Duration is fifteen (15), twenty (20)
3 10 and twenty five (25) years using not equal(!=) and and
operator
4 11 Display “Invalid Duration” using print function
5 16 Calculate TotalPayment
6 20 Display the Duration selected
7 24 Display variable TotalPayment with 2 decimal places
8 25 Display variable MonthlyPayment with 2 decimal places
Instructions

You might also like