Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

INFS5715 Programming for Data Analytics

Exam Practice Set

 Instructions:

1. Answer all 1 question(s).

2. Upload a ZIP file contains all the required files listed in the question(s). The file name of the ZIP file is “zID_INFS5715_Practice.ZIP”, e.g., z1234567_INFS5715_Practice.zip

 QUESTION 1 20 MARKS

Given an integer list int_num and an integer target int_target, return indices of the three numbers such that they add up to int_target.

You may assume that (1) the input list has at least three elements and (2) each input would have exactly one solution. You CANNOT use the same element twice. You can return the answer in any order

Example 1:

Input: int_num = [10, 2, 6, 8], target = 18

Output: [0, 1, 2]

Example 2:

Input: int_num = [100, 20, 10, 1, 6, 36, 80], target = 96

Output: [2, 4, 6]

Required:

(a) Briefly describe how you define a function that approach this question. Please answer this question using the provided Word answer sheet.

[Max. 100 words] (5 marks)

(b) Define a function called targetCheck with int_num and target being arguments, and return the required list targetInd. Submit a Jupyter Notebook with file name as “zID_Practice_Q1.ipynb”, e.g., z1234567_Practice_Q1.ipynb

You must follow the structure below:

 

Remark: You can define other function(s) to assist targetCheck() to accomplish its task. All defined functions must be arranged in a logical order and run without errors.

(15 marks)