Question

For this assignment, you need to submit a Python program that gathers the following employee information...

For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided:

  • Employee ID (this is required, and must be a number that is 7 or less digits long)
  • Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well.
  • Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters. It also cannot contain any of the following characters: ! " ' # $ % ^ & * ( ) = + , < > / ? ; : [ ] { } \ ).
  • Employee Address (this is not required, but if it is provided, it must be comprised primarily of alphanumeric characters. It cannot contain any of the following characters: ! " ' @ $ % ^ & * _ = + < > ? ; : [ ] { } ).
  • Employee salary (this is required, and must be a floating point number between 18 and 27)

Write your program so that it keeps asking for employee information until the user says they no longer wish to enter more users. Also, when a user enters improper data, the program must ask the user to re-enter it before continuing on.

As employee information is added, create a list of dictionaries that hold all of the information.

Once you have gathered all of the data into a list. You need to make the following modifications using comprehensions:

  • Add the words "IT Department" to each name in your list
  • Update salary information to be 30% higher than the number provided to reflect total salary information with benefits included

And the end of your program, print out the list of updated information.

Homework Answers

Answer #1

Code:-

def ID():
    while True:
        id_ = input("Enter employee ID: ")
        
        if id_ == "":
            print("Employee ID cannot be empty. Enter again.")
        elif len(id_) > 7:
            print("Employee ID should be less than or equal to 7. Enter again.")
        elif id_.isdigit():
            break
        else:
            print("The employee ID has non numeric characters. Enter again")
            
    return id_

def name():
    while True:
        name_ = input("Enter employee name: ")

        if name_.strip() == "":
            print("Employee name can not be empty.")
        elif name_.lower().replace("-", "").replace("'", "").replace(" ", "").isalpha():
            break
        else:
            print("Enter correct employee name.")
            
    return name_

def email():
    while True:
        email_ = input("Enter employee email: ")
        
        if len(set("!\"'#$%^&*()= +,<>/?;:[]{}\\").intersection(set(email_))) > 0:
            print("Do not use any of these characters: ! \" ' # $ % ^ & * ( ) = + , < > / ? ; : [ ] { } \\. Try again.")
        elif email_.strip().replace("@", "").replace(".", "").replace("_", "").isalnum():
            break
        else:
            print("Try again.")
            
    return email_

def salary():
    while True:
        salary_ = input("Enter salary: ")

        try:
            salary_ = float(salary_)
            if salary_ < 18 and salary_ > 27:
                print("Salary should be between 18 and 27")
            else:
                break
        except:
            print("The digit is not a floating point.")
            
    return salary_
employees = list()
while True:
    id_ = ID()
    name_ = name()
    email_ = email()
    salary_ = salary()
    
    employee = {
        "id": id_,
        "name": name_,
        "email": email_,
        "salary": salary_
    }
    
    employees.append(employee)
    
    quit = input("Do you want to quit? Y/N ").lower()
    if quit == "y":
        break
for employee in employees:
    employee["name"] = "IT Department" + employee["name"]
    employee["salary"] = employee["salary"] * 1.3
    
print(employees)

Screenshot of the above code with output:-

I hope this resolved your doubts. If you have further doubt do let me know. Regards.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000....
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
In this assignment, you will develop a Python program that will process applications for gala-type events...
In this assignment, you will develop a Python program that will process applications for gala-type events at a local dinner club. The club, Gala Events Inc., is currently booking events for the upcoming holidays. However, the club has the following restrictions: Due to the physical size of the building, its maximum occupancy for any event is 100—not including the club staff. Since local regulations do not permit the sale of alcoholic beverages after midnight, the maximum length of any event...
Payroll Management System C++ The project has multiple classes and sub-classes with numerous features within them....
Payroll Management System C++ The project has multiple classes and sub-classes with numerous features within them. Basic operations users can perform via this program project that are based on file handling are adding new employee record, modifying employee record and deleting record, displaying one or all employee’s record. Besides these, payroll management also allows users to print the salary slip for a particular employee. Features: 1. Addition of New Employee: You can find this feature under the public category of...
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes...
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes a ransom note. It is not wrriten by hand to avoid having his hand writing being recognized, so the kid napper uses a magazine to create a ransom note. We need to find out, given the ransom note string and magazine string, is it possible to given ransom note. The kidnapper can use individual characters of words. Here is how your program should work...
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must...
The following code to run as the described program on python. The extra test file isn't...
The following code to run as the described program on python. The extra test file isn't included here, assume it is a text file named "TXT" with a series of numbers for this purpose. In this lab you will need to take a test file Your program must include: Write a python program to open the test file provided. You will read in the numbers contained in the file and provide a total for the numbers as well as the...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...