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
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a...
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a name, an address, and a hire date. A name consists of a first name and a last name. An address consists of a street, a city, a state (2 characters), and a 5-digit zip code. A date consists of an integer month, day and year. All fields are required to be non-blank. The Date fields should be reasonably valid values (ex. month 1-12, day...
In Python write a program that prompts the user for six elements and their atomic numbers...
In Python write a program that prompts the user for six elements and their atomic numbers and stores them in a list. Each element and weight pair should also be a list. After the values have been entered, print the list as it entered. Then print the first two characters from the element names (the first character capitalized and the second in lower case) along with the atomic number, starting with the element with the lowest atomic number. You must...
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,...
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...
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...
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...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use arrays or vectors. All changes, calculations, etc should be performed in place ( in the file). You may need one or two structures that temporary hold data needed to be displayed, changed, etc. Part 2: Binary Files Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT