Inft1004 Assignment 2009 s1t1 School of Electrical Engineering and Computing Inft1004 Introduction to Programming – Assignment 2 Due 11.59pm on Sunday 9 May; students are advised to start work...

1 answer below »
Must be done with Python/Rodeo


Inft1004 Assignment 2009 s1t1 School of Electrical Engineering and Computing Inft1004 Introduction to Programming – Assignment 2 Due 11.59pm on Sunday 9 May; students are advised to start work immediately Weighting 30% Paired work Students are strongly encouraged to work in pairs on this assignment Your assessment task For this assignment you are to write a Python program that analyses results from the Simon Questionnaire for Understanding Aspiring Politicians (SQUAP). This is a questionnaire designed to assess potential politicians and suggest what positions they might be best suited for. It has just seven questions, each of which has eight possible answers. Here are three example questions. (You might find it fun to devise your own questions, but we don’t need all seven.) When a question makes me feel uncomfortable, I tend to respond by: (a) explaining that it makes me feel uncomfortable, then answering to the best of my ability (b) staring blankly at the questioner as if they were stupid (c) answering the question that I would have preferred them to ask me (d) saying that I will respond after seeking advice from the relevant department (e) attacking the questioner, for example by saying that their question is stupid (f) responding that the question should be answered by a member of the opposing party (g) saying the first remotely relevant thing that comes to my mind (h) looking at my watch, excusing myself, and leaving When a politician in my party is accused of profiting from questionable land deals: (a) I decline to comment because that should be the role of the party leader (b) I express empathy with any victims of the alleged behaviour (c) I decline to comment because the accusation should be investigated by the police (d) I suggest that it is in keeping with the politician’s past behaviour (e) I express my dismay at the accusation, and hope that it will prove to be unfounded (f) I remind the public and the press of similar accusations against members of other parties (g) I call on the media to say nothing about the accusation until it is established as fact (h) I call on my party to bring in measures to avert such behaviour in the future My perspective on taxation is that (a) it should be entirely abolished (b) I have thought of a far better way to administer it (c) it is a way of helping to distribute a country’s wealth (d) it is a necessary contribution to the cost of running the country (e) it is probably unfair, but is a reasonable way of raising funds (f) it is easily avoided with the right accounting techniques (g) it is a blight on the wealthy, forcing them to support those who won’t support themselves (h) politicians should be exempt because they already contribute in other ways Now this is not a standard multiple-choice questionnaire. Rather than choosing just one option for your answer, you are given ten points for each answer, and you divide them as you wish among the eight options. So for example, for the first question you might simply give all ten points to option b; whereas for the third question you might give five points to g, three points to h, and two points to a. Inft1004 Introduction to Programming Assignment 2 2 Your task is to write a Python program to process people’s answers to this questionnaire and let them know which political roles they seem best suited for. For the purposes of the program, the answer to a single question will be a set of eight integers, the points allocated to each of the options a to h. If somebody gives all ten points to option b, their answer to that question will be 0 10 0 0 0 0 0 0; if somebody gives five points to g, three points to h, and two points to a, their answer to that question will be 2 0 0 0 0 0 5 3. Once the program has the answers to all seven questions for a person, it puts them into the following grid. Notice that the cells of this grid are not in the order a to h: rather, each cell explicitly indicates which value goes into it. For example, in the first cell of question 6 the program will put the value for question 6 option e; in the second cell of question 6, the value for option d; in the third cell, the value for option f; and so on. Question RL RM RB LL LM LB CR CL 1 b: c: e: f: d: h: g: a: 2 c: f: a: b: g: e: d: h: 3 f: g: h: c: b: d: a: e: 4 h: a: c: d: e: b: f: g: 5 a: e: d: g: h: f: b: c: 6 e: d: f: a: c: g: h: b: 7 g: h: b: e: f: a: c: d: Here is a full example. If somebody gives the following answers to the seven questions (let’s call them the raw answers) . . . Question 1: 3 0 0 0 0 3 0 4 Question 2: 0 0 0 0 3 0 0 7 Question 3: 0 0 0 5 4 0 0 1 Question 4: 0 1 0 1 3 0 5 0 Question 5: 1 2 5 1 1 0 0 0 Question 6: 1 3 1 0 0 0 5 0 Question 7: 0 0 0 2 5 3 0 0 . . . the grid will be filled as follows . . . Question RL RM RB LL LM LB CR CL 1 b: 0 c: 0 e: 0 f: 3 d: 0 h: 4 g: 0 a: 3 2 c: 0 f: 0 a: 0 b: 0 g: 0 e: 3 d: 0 h: 7 3 f: 0 g: 0 h: 1 c: 0 b: 0 d: 5 a: 0 e: 4 4 h: 0 a: 0 c: 0 d: 1 e: 3 b: 1 f: 0 g: 5 5 a: 1 e: 1 d: 1 g: 0 h: 0 f: 0 b: 2 c: 5 6 e: 0 d: 0 f: 0 a: 1 c: 1 g: 5 h: 0 b: 3 7 g: 0 h: 0 b: 0 e: 5 f: 3 a: 0 c: 0 d: 2 Total 1 1 2 10 7 18 2 29 The program then sums the values in each column, and looks for the two biggest values. In this case they are the CL column, with 29, and the LB column, with 18. These columns are then used to indicate what political roles the person seems best suited to. While the assignment will undoubtedly seem daunting at first, we have broken it into a number of tasks, each of which is described in the sections below. If you tackle just one task at a time, and don’t move on until you have completed that task, you might be surprised at the program that you will eventually produce. Inft1004 Introduction to Programming Assignment 2 3 Journal As programming is a complex task, you are required to maintain and submit a journal, a separate word-processed document that includes: • A title page o Assignment heading and description o Team members’ names, student numbers, lab sessions • An entry for each session of work on the assignment o Day, time, and date; eg Day 1: Monday 1 April, 10-11am o Which aspects of the assignment are worked on o Which bits are done by which member(s) of the pair o Questions that arise, difficulties that you encounter, and how you overcome them • Conclusion o An overall conclusion for the journal o What was not completed, and why o Lessons that you have learnt o Suggestions for students in the next offering of this course to help them complete the work o References to any external person or source that you use (in a consistent style, such as APA where appropriate) • Footers o With your names and page numbers By the time you’ve finished the program your journal will probably be many pages long. The journal is intended to record your design thoughts, your programming thoughts, and the time you spend on the task, so you must keep it up to date at all times. A ‘journal’ that is thrown together a few days before the assignment is due is not a journal at all. When you hand in your files, your journal must be a pdf file. Cover sheet – not required The university does not require cover sheets for online submissions. Files and folders When you hand in the assignment you will be handing in two files: your Python program and your pdf journal. There is a particular structure that you are required to follow. Both files (and no other files) will be in a folder whose name is your names, without spaces, followed by the abbreviation Assgt2. If Abby Archer and Zeke Zammit are working together, their folder will be called AbbyArcherZekeZammitAssgt2. Within that folder, your Python program will have your names followed by Assgt2.py (eg AbbyArcherZekeZammitAssgt2.py); and your journal will have your names followed by Journal.pdf, (eg AbbyArcherZekeZammitJournal.pdf). Remember that the journal is to be a pdf file. Problem solving Several aspects of this assignment involve problem solving. This is not unusual: it is difficult to specify programming tasks that do not require problem solving. While you might be tempted to just write some code and hope that it will eventually do what you want it to do, in the end it will be far more effective to first work out exactly what you want the code to do, and only then start writing the code. Based on past experience, students who believe that they are having trouble with their program code are generally having trouble with their program design, their algorithm. If your program isn’t doing Inft1004 Introduction to Programming Assignment 2 4 what you want it to do, this is probably because you haven’t solved the problem and clearly worked out how the program should do what you want it to do. You are most unlikely to get the program working correctly if you haven’t correctly solved the problems and designed the solutions. When you need to problem-solve, the key is
Answered 2 days AfterMay 06, 2021INFT 1004University Of South Australia

Answer To: Inft1004 Assignment 2009 s1t1 School of Electrical Engineering and Computing Inft1004 Introduction...

Pratap answered on May 08 2021
158 Votes
"""
SQUAP Result Analyser Program
"""
def analyse_csv(filename, filetype):
"""
Function to read the input file
and store the lines as list
:param filename: name of the file to read
:param file
type: 'raw' or 'preprocessed'
:return: None
"""
f = open(filename, "r")
names = []
answers = []
lines = f.readlines()
for i in range(1, len(lines)+1, 8):
temp = list()
names.append(lines[i-1].rstrip().lstrip().split(",")[0])
for j in range(1, 8):
temp2 = lines[i+j-1].rstrip().lstrip().split(",")[1:]
temp.append(temp2)
answers.append(temp)
f.close()
process_candidate(names, answers, filetype)
def process_candidate(candidate, file_lines, filetype):
"""
Function to transform the data from the list
:param candidate: list of candidate names
:param file_lines: list of candidate's answers
:param filetype: 'raw' or 'preprocessed'
:return: None
"""
for i in range(len(file_lines)):
for j in range(len(file_lines[i])):
for k in range(len(file_lines[i][j])):
try:
if file_lines[i][j][k] == '':
file_lines[i][j][k] = '0'
file_lines[i][j][k] = int(file_lines[i][j][k])
except:
pass
for item in range(len(file_lines)):
echo_answers(candidate[item], file_lines[item], filetype)
if filetype == "raw":
result = translate(file_lines[item])
else:
result = file_lines[item]
translated_result = analyse(result)
sort_descending(translated_result)
display(translated_result)
def echo_answers(candidate_name, answer_list, filetype):
"""
Function to display the candidate's questionaire answers
:param candidate_name: name of the candidate
:param answer_list: list of candidate's answers
:param filetype: 'raw' or 'preprocessed'
:return: None
"""
print(
"\nQuestionaire answers ({}) for {}".format(filetype, candidate_name),
)
for i in range(len(answer_list)):
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here