I guys, I really need some help with this assignment for python 3.6. Thank you v
ID: 3788149 • Letter: I
Question
I guys, I really need some help with this assignment for python 3.6. Thank you very much in adavanced!
Assignment: You will create a Python program (named: LastnameFirstInitial_PA3) to calculate the total net paycheck and userid using the following is the information.
Data to be input ( things the user will be prompted to type in)
1. Employee Name (first & last)
2. Number of hours worked Hourly
3. Pay rate
4. Married or Single (to determine Federal tax rate)***
5. State tax rate (as a percentage, let the user input the rate)
***Married tax rate 10%, Single tax rate 15% (use decision statement to test first letter only, make sure to changethe capitalization to what you are testing)
Determine userid:
Combine the following 3 strings to determine userid. You will use string functions, methods, and operators for this. Part 1. take the slice that starts at the position numbered by the length of the string integer divided by 3 and includes up to character 7 (see 2 examples) Part 2. take the last 3 letters in capitals Part 3. take the min and max
Explanation / Answer
Hi,
Creation of userid is not determined properly. You should have given few examples. Anyway i have assumed in the following way and created the userid
Part1: index 0:length/3 in the name string
Part2: last 3 letters in Capital
Part3: First and last letter of the name string
Code:
#!/usr/bin/python3
def calculateuid(mylist):
paylist=[]
for tup in mylist:
length=len(tup[0])
tmp=int(length/3)
mystr=tup[0][0:tmp]
mystr= mystr+tup[0][-3:].upper()
mystr=mystr+tup[0][0]+tup[0][length-1]
grosspay=tup[1] * tup[2];
tax= (grosspay * tup[4])/100
netpay=grosspay-tax
paylist.append((mystr,netpay))
return paylist
count=input("Enter total employees: ")
count=int(count)
mylist=[]
for i in(range(count)):
name=input("Enter employee "+str(i+1)+" name:")
hours=input("Enter number of hours worked:")
hours=int(hours)
payrate=input("Enter payrate:")
payrate=int(payrate)
married=input("Married(M)/Single(S):")
married=married.upper()
if married == "M":
tax=10
else:
tax=15
mylist.append((name,hours,payrate,married,tax))
paylist=calculateuid(mylist)
print("Userid Totay Pay")
print("===========================")
for tup in paylist:
print(tup[0]+" "+str(tup[1]))
Output:
$ python3 LastnameFirstInitial_PA3.py
Enter total employees: 3
Enter employee 1 name:AlexWanders
Enter number of hours worked:450
Enter payrate:34
Married(M)/Single(S):M
Enter employee 2 name:StanleyRong
Enter number of hours worked:40
Enter payrate:650
Married(M)/Single(S):S
Enter employee 3 name:DaleRathunde
Enter number of hours worked:120
Enter payrate:340
Married(M)/Single(S):M
Userid Totay Pay
===========================
AleERSAs 13770.0
StaONGSg 22100.0
DaleNDEDe 36720.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.