0% found this document useful (0 votes)
66 views

Programming Assignment Unit 6

The document outlines a programming assignment focused on list operations in Python, specifically for managing employee data in an HR context. It includes tasks such as splitting a list of employee names, adding a new employee, updating salaries, and manipulating strings. The assignment aims to enhance practical skills in data management through hands-on coding exercises.

Uploaded by

ashigull487
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)
66 views

Programming Assignment Unit 6

The document outlines a programming assignment focused on list operations in Python, specifically for managing employee data in an HR context. It includes tasks such as splitting a list of employee names, adding a new employee, updating salaries, and manipulating strings. The assignment aims to enhance practical skills in data management through hands-on coding exercises.

Uploaded by

ashigull487
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
You are on page 1/ 7

1

Programming Assignment Unit 6

Ayesha Gul

University of the People

CS 1101: Programming Fundamentals

Dr Josiah Jolaoluwa

13th of March, 2025


2
Programming Assignment Unit 6

By the end of this assignment, you will be able to perform addition, deletion, and sorting on the

elements of the list as well shall be able to experiment list and related operators

(a). Consider that you are working as Data Analyst in an organization. The HR department needs

you to carry out following operation on existing list of 10 employees name (you can assume 10

names in a list here).

Split the list into two sub-list namely subList1 and subList2, each containing 5 names.

A new employee (assume the name “Kriti Brown”) joins, and you must add that name in

subList2.

Remove the second employee's name from subList1.

Merge both the lists.

Assume there is another list salaryList that stores salary of these employees. Give a rise of 4% to

every employee and update the salaryList.

Sort the SalaryList and show top 3 salaries.

Write the Python code and output for the same.

(b). Design a program such that it converts a sentence into wordlist. Reverse the wordlist then.

Write the code and output for the same.

Answer:

Lists are one of the most fundamental data structures in Python, allowing efficient

storage, manipulation, and organization of data. This assignment explores various list operations,

including addition, deletion, sorting, and merging, within a practical HR scenario. In the first

part, we work with a list of employee names, perform operations like splitting, adding, removing,

and updating salary records with a percentage increase. The second part demonstrates string
3
Programming Assignment Unit 6

manipulation by converting a sentence into a word list and reversing it. These exercises provide

hands-on experience with list-related functions, enhancing data management skills crucial for

real-world applications.

Part 1:

Input:

Explanation:

The input for this part consists of a list of 10 employee names based on Stranger Things

characters. The names are initially stored in the employees list. The list is then split into two

sub-lists: subList1 contains the first five names, and subList2 contains the remaining five. A new

employee, "Kriti Brown," is added to subList2, and the second employee in subList1 is removed.

The modified sub-lists are then merged to form a final list, mergedList. Additionally, a salaryList
4
Programming Assignment Unit 6

is provided, where each salary is increased by 4%, and the updated salaries are stored in

updatedSalaryList. The list is sorted in descending order, and the top three salaries are extracted

and displayed.

Output:

Explanation:

The output displays the modified sub-lists after addition and deletion operations. It then presents

the final merged employee list. The updated salary list, which includes a 4% raise for each

employee, is shown next. Finally, the top three highest salaries from the sorted salary list are

displayed. These results demonstrate list operations such as slicing, appending, deletion,

merging, sorting, and applying calculations using list comprehensions.

Part 2:

Input:
5
Programming Assignment Unit 6

Explanation:

The input for this part consists of a sentence, "Stranger Things is an amazing series", which is

stored in the sentence variable. The program converts this sentence into a list of words using the

.split() function. The resulting word_list contains each word as a separate element in a list.

Output:

Explanation:

The program first prints the word_list, showing the sentence split into individual words. Then, it
6
Programming Assignment Unit 6

reverses the list using the reversed() function and stores the result in reversed_word_list. Finally,

the reversed word list is printed, displaying the sentence with words in reverse order. This part of

the assignment highlights string manipulation techniques, particularly list conversion and

reversal.
7
Reference List

Using Python on Windows. (n.d.). Python Documentation.

https://docs.python.org/3/using/windows.html

Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press.

https://greenteapress.com/thinkpython2/thinkpython2.pdf

You might also like