[Using Python] Create a program that uses import random and while loops to generate one random question, from a list of 5, for each repeated run. Report the number of the correct answers after all five questions have been answered.
Your 5 questions should be a simple math problem, like "what is 7-5?"
import random as r#to import random library
i=0#iterable
lis = ['what is 2-3',
'what is 3*5?',
'Value of 6+9',
'What is 7-5',
'What is 14/7']#list of simple math questions
ans = [-1,15,15,2,2]#Answers for the given questions
check=[0]*5#To check the question is already asked or not.
score=0#variable to store the score of the user
while(i!=5):#loop to ask 5 questions
c = r.randint(0,4)#generate the random number in the range of
questions.
if(check[c]==0):#condition to check if the question is not
answered.
print(lis[c])#Ask the question
a = int(input())#Takes the answer from the user.
if(a==ans[c]):#check whether the user's answer is correct or
wrong
score=score+1#If the answer is correct it increments the
score.
i+=1#to iterate the loop.
check[c]=1#To ensure the question was already asked.
print('Score is',score)#It prints the score.
OUTPUT:-

For any queries please do comment.
Please Like if you are satisfied.
[Using Python] Create a program that uses import random and while loops to generate one random...
[Using Python] Create a program to generate one random question, from a list of 5, for each repeated run. Report the number of the correct answers after all five questions have been answered. Your 5 questions should be a simple math problem, like "what is 5-4?" use a while loop based on the number of questions use a counter variable to count the number of questions asked e.g. questionCount +=1 user a counter variable to keep track of the correct...
Create a program using the Random class and While loops in Java. The program should generate a random number from 50 through 100. The loop should add the five random numbers generated. On each iteration of the loop the program should print out the number generated, how many numbers have been generated thus far, and the sum so far. On the last iteration, the printout should say the The final total is.... Teach comment the last time I did it:...
Using simple python code import random Your program should: generate positive random integers in the range of 1 to 500 count the number of iterations. update and output the highest number generated.
Python please Create a menu-driven modular program so user can take a 10-question math quiz, Addition or subtraction, at specified difficulty level. Easy(1-digit), Intermediate(2-digit), and Hard(3-digit). After a quiz, display the quiz type and level, and number of correct questions user answered.
Write a Python program that generate randomly a magic square of 3 x 3 elements. For example: 4 3 8 9 5 1 2 7 6 = Matrix1 Matrix 1 above is an example of magic square. The rows total, the columns total, and the diagonal totals are all 15. Your program should randomly generate a 3x3 matrix. Check if it is a magic square. If it is a magic square, then print some information and quit. If the...
THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM FOR PYTHON This time, we will write a program that uses functions to parse through all those names in a List object (see below for the "us_counties" list) to count the number of occurrences each vowel (a, e, i, o, u) has in all the names. We want 5 separate answers, one for each vowel. Not looking for output here. All my solution will...
OBJECTIVES: To understand repetition structures To use while loops in a program To understand break and/or continue instructions Write a Python program (with comments) to do the following: Create a variable count and initialize it to 0 Create a variable colors and initialize it to [] (i.e. an empty list) Ask the user if they would like to enter up to 3 favorite colors. They should enter ‘y’ or ‘n’. Assume they will enter a valid input. Save the response...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
import random
def doTest(operation):
## complete your work here ##
# return True for now
return True
responsesCorrect = 0
print("The software will process a test with 10 questions ……
")
for compteur in range (10):
operation = random.randint(0,1)
if doTest(operation) == True:
responsesCorrect += 1
print(responsesCorrect, "Correct responses")
if responsesCorrect <= 6 :
print("Ask some help from your instructor.")
else:
print("Congratulations!")
Requirement: You must use the format provided below and
then complete the fill! Python! Thanks!...
python
Create a program to open a text file for reading, find the maximum number in the file, determine if that maximum number is even, and write to an output text file. You should either write Yes if the number is even, otherwise write the maximum number. You should note the following: • Your input file must be named input.txt • The input file has one integer number per line • Your output file must be named output.txt • Your...