131k views
5 votes
Create and combine the following 4 strings to determine the user’s initial Access Code (beware of extra spaces). You will use string functions, methods, and operators for this.

1. Get the max letters/characters from the name
2. Use integer division to divide the length of the name string by 3. Use the portion of the name that starts at that position number, and includes up to the character in position 10 (see examples below)
3. Use the last 2 letters, in upper case
4. Use the third letters from the user’s first and last names and the minimum character of the last name

User John Elion
by
2.9k points

1 Answer

6 votes

Answer:

Python script for the problem is provided below

Step-by-step explanation:

name = input("Employee Name: ")

hoursWorked = input("\\Hours Worked: ")

payRate = input("Pay Rate: $")

hoursWorked = int(hoursWorked)

payRate = float(payRate)

grossPay = payRate*hoursWorked

print("Deduction: ")

print("\tFederal Withholding(10%): $",round(grossPay*.1,2))

print("\tState Withholding(6%): $",round(grossPay*.06,2))

print("\tTotal Deduction: $",round((grossPay*.1+grossPay*.06),2))

print("Net Pay check: $",round((grossPay-(grossPay*.1+grossPay*.06)),2))

print("Your new access code is: ")

lengthOfName = len(name)

index = int(lengthOfName/3);

firstName = name.split(" ")[0]

lastName = name.split(" ")[1]

print(name[index:11]+name[len(name)-2:len(name)].upper()+firstName[2]+lastName[2]+lastName[0])

User Jimidy
by
3.3k points