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
Write a program segment that simulates flipping a coin 25 times by generating and displaying 25 random integers, each of which i
Angelina_Jolie [31]

Answer:

//import the Random class

import java.util.Random;

//Begin class definition

public class CoinFlipper {

   //The main method

    public static void main(String []args){

       

       //Create an object of the Random class

       Random ran = new Random();

       System.out.println("Result");    

       //Use the object and the number of times for simulation

       //to call the flipCoin method

       flipCoin(ran, 25);

    } //End of main method

   

   

    //Method to flip coin

    public static void flipCoin(Random ran, int nooftimes){

        //Create a loop to run as many times as specified in variable nooftimes

       for(int i=1; i<=nooftimes; i++)

           System.out.println(ran.nextInt(2) + 1);

    }

}   //End of class definition

====================================================

Sample Output:

Result

1

1

1

2

1

2

2

1

2

1

1

2

1

2

1

1

1

2

1

1

1

2

2

1

2

========================================================

Explanation:

The above code has been written in Java. It contains comments explaining every part of the code. Please go through the comments.

The sample output from the execution of the code is also given above.

The code is re-written as follows without comments.

import java.util.Random;

public class CoinFlipper {

    public static void main(String []args){

       Random ran = new Random();

       System.out.println("Result");    

       flipCoin(ran, 25);

    }

   

    public static void flipCoin(Random ran, int nooftimes){

       for(int i=1; i<=nooftimes; i++)

           System.out.println(ran.nextInt(2) + 1);

    }

}

8 0
3 years ago
A file containing user information which is transmitted from an online server and attached to your web browser and stored on you
Vlada [557]
The answer is : Virus<span />
4 0
3 years ago
What is the purpose of using variables in programming?
Sedbober [7]
Variables are used to store information to be referenced and manipulated in a computer program. ... It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
6 0
3 years ago
The process of sending a result back to another part of the program is
Oksi-84 [34.3K]

Answer:

The process of sending a result back to another part of the program is known as pushing a value False In Python, functions and other resources are coded in components called modules

Explanation:

4 0
3 years ago
The numbering system we commonly use is called the decimal numbering system because it uses ________ symbols to represent all po
mojhsa [17]

Answer:

10.

Explanation:

Decimal numbering system is a number system which has ten digits. These ten digits are 0,1,2,3,4,5,6,7,8 and 9. It has signed and unsigned digits. The signed digits represents negative values of digit with the minus "-" sign written before the digit. The unsigned digits have no sign before them.

Binary numbering system has only 1 and 0 digits, while the hexadecimal number system has 16 digits.

6 0
3 years ago
Other questions:
  • WILL MARK BRAINLYIST
    15·2 answers
  • Is there any level after genius?
    8·1 answer
  • Write a number guessing game. The game should have a default 1-100 picking system. Have the user guess the number the computer p
    12·1 answer
  • What are the different steps while solving a problem using computer? explain​
    7·1 answer
  • A program that doesn’t work properly needs to be debugged. true or false
    8·1 answer
  • Kerry is debugging a program. She identifies a line of code to begin execution and a line of code to end execution so that she i
    11·1 answer
  • The science of how an object reacts to its motion through air is called _______________. (12 letters)
    13·2 answers
  • Why is computer called information processing machine ?????​
    6·2 answers
  • Difference between software developer and software engineer.
    6·1 answer
  • A common business practice is to include a worksheet named Documentation that contains a description of the workbook, the name o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!