You are going to write a program for Computer test which will read 10 questions from a file, order them randomly and provide the test to the user. When the user done the program must give the user his final score

Respuesta :

Answer:

from pprint import pprint

import random

match = {

   "mcq1": "a",

   "mcq2": "c",

   "mcq3": "c",

   "mcq4": "d",

   "mcq5": "a",

   "mcq6": "a",

   "mcq7": "a",

   "mcq8": "b",

   "mcq9": "d",

   "mcq10": "a"

}

file = open("test","r")

questions = set()

for i in range(10):

   ques = []

   for line in file:

       if "-" in line:

           break

       else:

           ques.append(line)

   questions.add(tuple(ques))

def quiz(questions, match):

   questions = list(questions)

   marks = 0

   for i in range(10):

       pprint(questions[i])

       mcq = "mcq",str(i+1)

       mcq = list(mcq)

       answer = input("enter your answer: ")

       if answer == match["".join(mcq)]:

           marks += 1

   return marks

print("Your score is: ",quiz(questions, match))

Explanation:

the file which has been loaded is test, and its data is provided below...

mcq1. The device which converts analog signals to digtital signals and vice versa is called.

a) mother board

b) TAP

c) Modem

d) I/O device

-

mcq2. The main components of a computer system are.

a) TAP, CPU, Printer

b) CPU, Input device

c) CPU, ALU, CU

d) CPU , Output device , Memory unit, Control unit

-

mcq3. A source program is a program.

a) writter in machine laguage

b) translated in machine langaue

c) written in high level language

d) required to boot a computer

-

mcq4.Which image format supports transparency in images.

a) PNG

b) GIF

c) JPG

d) A & B

-

mcq5. (10111) 2 = (?) 10.

a) 23

b) 50

c) 24

d) 89

-

mcq6. UNICODE is an example of.

a) character encoding set

b) driver

c) software

d) database

-

mcq7. (10111) 2 = (?) 10.

a) 23

b) 50

c) 24

d) 89

-

mcq8. NTFS stand for.

a) Network File Saving

b) New Technology File System

c) Newt Trend File Saving

d) Non Technology File System

-

mcq9. FF is example of.

a) Octal number system

b) Binary Number System

c) Decimal Number System

d) Hexadecimal number system

-

mcq10. Emails are sent with the help of ?

a) SMTP

b) FTP

c) HTTP

d) UDP

-

Answer:

running the program with test data to see if outcomes are as expected (b)

Explanation:

RELAXING NOICE
Relax