my python code has some bugs
For unlimited access to Homework Help, a Homework+ subscription is required.
Part (a) [3 MARKS] Consider this program: Fill in the Python Shell output after this program has executed. >>> X L = [4, 10, 8] X = L. sort L.append(20) L2 = L[1:] >>> L >>> id(L) == id(L2)
Question 4. [4 MARKS] You decide to save all your passwords in files, one password per file. You then decide you want to update your 6-character UTORid password, but you don't remember which of your password files you saved it in. Luckily, this is the only 6-character password you have so you decide to write a function to find the password and change it. Your code runs, but the function's body contains four bugs which will result in the function execution not matching its docstring description. In the space provided, rewrite the buggy lines with the bugs fixed. Do not add or remove any lines. def change password(files_list, new-password): " (list of str, str) -> str Preconditions: (1) files list is not empty. (2) Each file in files_list contains one single-line password. (3) All files in files_list contain passwords of different lengths. (4) Your 6-character password is guaranteed to be in one of these files. In the appropriate file from files_list, replace your 6-character password with new-password, and return your old password. #Code If you think a given line contains a bug, rewrite it. Otherwise leave it blank. found = True for filename in files list[:-1]: passwd_file = open(filename, 'r') first line = passwd_file.read() password = first line.strip("2") if password == 6: passwd_file.close() passwd_file = open(filename, 'w') passwd_file.write(new_password) found = True passwd_file.close() if found: # This is correct. Do not modify. return password
Using Hadoop for historical sales data analysis
Use this dataset to analyze various aspects of transaction
1) Average unit_price by country for a given item type in a certain year
2) Total units_sold by year for a given country and a given item type
3) Find the max and min units_sold in any order for each year by country for a given item type. Use a custom partitioner class instead of default hash based.
4) What are the top 10 order id for a given year by the total_profit
Please help in doing above analysis working on a Hadoop system using map reduce code, written either in Java or Python. Data preparation steps can be done as required before running a MapReduce job to answer questions above.
Dataset: