1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sauron [17]
3 years ago
13

*Python Coding

Computers and Technology
1 answer:
Reika [66]3 years ago
4 0

correct = (["1.B", "6.A", "11.B", "16.C","2.D", "7.B", "12.C", "17.C", "3.A", "8.A", "13.D", "18.B","4.A" ,"9.C", "14.A", "19.D","5.C", "10.D", "15.D", "20.A"])

f = open("MyFile.txt", "r")

user_answers = ([])

count = 0

txt = ""

for x in f.read():

   if x == " " or x == "\n":

       x = ""

       count += 1

   if count == 2 :

       user_answers.append(txt)

       txt = ""

       count = 0

   txt += x

i = 0

cor = 0

wrong = ([])

while i < len(correct):

   if correct[i] == user_answers[i]:

       cor += 1

   else:

       wrong.append(user_answers[i])

   i += 1

questions = ([])

for i in wrong:

   txt = ""

   for w in i:

       if w == ".":

           questions.append(int(txt))

       txt+=w

print("There were {} correct answers".format(cor))

print("There were {} incorrect answers".format(len(questions)))

print("The incorrectly answered questions are {}".format(questions))

f.close()

The file I used for testing looks like:

1. C 6. A 11. B 16. C

2. D 7. B 12. C 17. C

3. A 8. D 13. D 18. D

4. A 9. C 14. A 19. A

5. C 10. D 15. D 20. C

The code only works if there is a new line after 20. C (press enter after that question if a new line isn't already included)

I hope this helps!

You might be interested in
......... mi2hej<br><br>ejid8eo19o1b2bxhxjxjdnneejk2929nr
Mila [183]

Answer:

hi  thsu si s5

Explanation:

brace use

5 0
3 years ago
Read 2 more answers
Use the drop-down menus to complete the statements about creating a table of contents in Word 2016.
siniylev [52]

Answer:

1.headings and subheadings

2.manually

3.options

6 0
3 years ago
Which team won the first World Series ?
Ulleksa [173]
Boston Red Sox, Boyo
5 0
3 years ago
Read 2 more answers
What is the biggest danger when you reveal information such as your Social Security number?
Dima020 [189]

based off my knowledge im gonna to go with OPTION A because ur social security number holds information like your brith etc

6 0
3 years ago
Read 2 more answers
Anyone here good with PS4's?
Nookie1986 [14]
I can help you out ! What do you need to know bud ?
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the input output ratio if its 12/23
    7·1 answer
  • How to remove a channel from favorite list on suddenlink?
    15·1 answer
  • Wireless networks are the most difficult type of network to set up <br> true or false
    15·1 answer
  • This diagram shows a number of computing devices connected to the Internet with each line representing a direct connection.
    11·1 answer
  • NAND is logically complete. Use only NAND gates to constructgate-level circuits that compute the
    7·1 answer
  • Which of the following would be the most appropriate way to address and greet your teacher, Mr. Joseph Herman, in an email? Hi J
    7·1 answer
  • Examples of application software​
    7·2 answers
  • What is a cookie? *
    9·2 answers
  • QUESTION 5
    9·1 answer
  • Online platforms that allow users to represent themselves via a profile on a web site and provide and receive links to other net
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!