python beginner help

percussionman11

Baseband Member
Messages
63
Location
United States
I'm working on some homework due tonight and really struggling. Being that it is an online course I have nobody to talk to except the professor and you guys and her help hours were yesterday (didn't get over there due to work). I'm not outright asking for answers so much as help. If you give answers an explanation would be appreciated as I am trying to learn the materials.

Here is the file needing help:
https://drive.google.com/file/d/0BzCBwP9t-_VDSTRyckZMNVAtbms/edit?usp=sharing

There are two other files I'm not attaching as they are just text files with A,B,C,D as answers like a mock test but they are titled "correct_answers.txt" and "user_answers.txt"

This is the assignment and changes I'm struggling with:
- Make the following change to the main() function:
* Add code to the loop in lines 30-31 to compare the contents of the 2 lists and an update the correct_count and num_questions variables

- Make the following change to the populate_list function:
* read the file passed in as the first parameter. Each record in the file should be placed as an element in the list sent is as the second parameter.

Any and all assistance would be helpful as this is my first programming class and I am very new to this. The whole chapter and assignment is on Lists & Tuples if it isn't obvious.

Thanks in advance!
 
Well for the first one you'd do something like (sort of pseudocode, I've never coded in Python.. so here it is in C++ :tongue:)
if (correctanswer == useranswer) correctcount++;
else incorrectcount++;

As for the populate list function, you would add each element read from the file to the array.

ie,

for each line "i" in the file do this:
array = line of file

ie, this will read each line of the file and stick that line into the i position of the array, where the i position relates to the line of the file you are on.

you'll have to google or wait for another member to respond for this one as I don't know python syntax.
 
Back
Top Bottom