CS代考 AD599 Assignment 1 task 2-5 shell script

# Task 1: Finish the codes in each question (1 point for whole Task 1)

Copyright By PowCoder代写 加微信 powcoder

#Question 1.1 – Create a ranked list of your five favorite foods (#1 is first, #2 is second, etc.)
fav_foods = ###your codes here
fav_foods=(pizza,Chickren)

#Question 1.2 – After dining in Boston, you discover a new #2 food!
#tell us what it is and insert it into the #2 position in ‘fav_foods’
###your codes here
fav_foods=(pizza,Chickren)
Print fav_foods

#Question 1.3 – remove duplicate entries from the list ‘repeats’ and name it ‘no_repeats’
repeats = [‘Bada’,’Bing’,’Bada’,’Boom’]
no_repeats = # your codes here

#Question 1.4 – Given lists ‘first’ and ‘second’, append the two lists together
first = [‘Eenie’,’Meanie’]
second = [‘Mynie’,’Mo’]
together = # your codes here

#Question 1.5 – Create a list containing all the square roots for integers between 1 and 6 (1 line)
srrt_list = #your codes here
print(srrt_list)

#Question 1.6 – For the list ‘nums_with_zeros’, move all of the zeros to the end of the list (2 lines)
nums_with_zeros = [2,3,0,0,4,6,7,0,0,0,1,8,10]
zeros_at_end = # your codes here
#End task 1 code

#AD599 Assignment 1 task 2-5 shell script

Things to cover in this assignment:
-Flow Control (if-else, try-except, assert)
-Conditional Logic
-Text and Strings
-Formatting and printing

This script simulates the results of a job entrance exam where applicants
complete tests and receive scores.

Your task here is to complete the code required to intake the results of the test,
report the results and make hiring recommendations based on the test results.
import random
random.seed(123)
num_applicants = 100
num_questions = 20
#results from the 20-question exam
results_sheet = []
for student in range(num_applicants):
#generate scores for each student and append to results_sheet
scores = random.choices(list(range(0,6)),k=num_questions)
results_sheet.append(scores)
#The result here is a list of lists.

#print out the first row of scores just as an example
print(results_sheet[0])
[0, 0, 2, 0, 5, 0, 3, 1, 5, 0, 2, 2, 1, 0, 2, 0, 3, 0, 1, 2]

# Task 2: define a function named sum_score and use it to sum the values in results_sheet (1 points)

# Codes for the sum_score function
def sumscore(a):
#your codes here

#CODES TO SUM AND REPORT THE TOTAL RESULTS
#’totals’ should be a list of length = ‘num_applicants’ with the totals for each applicant
#HINT: you will need a for-loop here

totals = []
# your codes here

#Task 3: Use try-except to check for an error with a list data type (1 point)
next_applicant contains values that don’t make sense to add up
maybe as a result of a typing mistake?
next_applicant = [0,4,2,3,’O’,5,1,2,4,4,2,3,’O’,4,5,’O’,1,2,3,4]
Use the module and function from task 1 above to try and sum the values in
‘next_applicant’ and show that an error is returned.
HINT: You will need to identify what is wrong with ‘next_applicant’ in the code.
We can see that there are the letter ‘O’ in the list instead of number 0,
but you need to help the program recognize that.
#Your codes here

#Task 4: Use if-else and elif to filter lists (2 points)
results_sheet has a total of 100 summed values in it now, representing the scores
on a job entrance exam. You now need to do two things:
-Add an index to the list, i.e. the first applicant should be number 1, and so on.
-filter all the applicants into categories
-the categories are represented as lists: ‘make_an_offer’, ‘waitlist’, ‘no_offer’
-the minimum scores for being included in each
-‘make_an_offer’:60
-‘waitlist’: 50
-‘no_offer’: <50 -each elements in the lists above should have 2 parts: -applicant number -total score make_an_offer = [] waitlist = [] no_offer = [] #Your codes here #Task 5: Use text and strings to report the results of the script (2 points) Now equipped with the scores for all the applicants, you can take the appropriate actions. For the applicants in 'make_an_offer', we will generate text to put in an offer letter. For 'waitlist' candidates, we will generate different text, and for 'no_offer' applicants, we will send a third string of text. The templates are below. You need to complete 2 tasks: -You need to generate a string for each of the 100 candidates, depending on which category they are in. -Use those string to create a list of strings in APPLICANT NUMBER ORDER, i.e. applicant #1 should be first, #2 second, etc. called 'letter_text' offer_text = '''Congratulations {}! Your score of {} on the exam has earned you an offer from our company.''' waitlist_text = '''Hello applicant {}! Your score of {} was good, and we appreciate your desire to work here.''' no_offer_text = '''Hi applicant {}. Unfortunately your score of {} was strong enough with the high quality of applicants.''' letter_text = [] #Your codes here 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com