CS 1101-01 Unit 6
CS 1101-01 Unit 6
Sarah Hauya
To preable, this essay will answer the two parts of the problems given below;
(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).
1. Split the list into two sub-list namely subList1 and subList2, each containing 5 names.
2. A new employee (assume the name “Kriti Brown”) joins, and you must add that name in subList2.
4. Assume there is another list salaryList that stores salary of these employees. Give a rise of 4% to
every employee and update the salaryList.
employeeList = ["Alice", "Bob", "Charlie", "David", "Eve", "Frank", "Grace", "Helen", "Isaac", "Jack"]
subList2.append(new_employee)
# List of salariessalaryList = [50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000]
salaryList.sort(reverse=True)
Show the top 3 salaries
top_3_salaries = salaryList[:3]
print("SubList1:", subList1)
print("SubList2:", subList2)
(b). Design a program such that it converts a sentence into wordlist. Reverse the wordlist then. Write
the code and output for the same.
def sentence_to_wordlist(sentence):
# Split the sentence into words using whitespace as a separator wordlist = sentence.split() return
wordlist
return reversed_wordlist
# Input sentence
input_sentence = " Mosquitoes are small, violent, and mischievous creatures in overalls."
word_list = sentence_to_wordlist(input_sentence)
reversed_word_list = reverse_wordlist(word_list)
print(word_list)
Conclusion
To conclude, above are respondes to the two sets of questions given in this assignment in regards to
computer programming.