Question

Question 4 Modify your Python program from Q1 that are randomly distributed between multiplication and addition. It should alimport random def doTest(operation) ## complete your work here ## # return True for now return True 0 responsesCorrect print(

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!

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import random


def doTest(operation):
    num1=random.randint(0,9)
    num2=random.randint(0,9)
    if operation==1:
        res=num1*num2
        answer=int(input('Enter the result of {:d} * {:d}: '.format(num1,num2)))
        if answer==num1*num2:
            return True
    else:
        res=num1+num2
        answer = int(input('Enter the result of {:d} + {:d}: '.format(num1, num2)))
        if answer == num1 + num2:
            return True
    print('Incorrect! The correct answer is',res)
    return False


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!")

In [1]: import random def doTest(operation): numl=random.randint(0,9) num2=random.randint(0,9) if operation=-1: res=numinum2

Add a comment
Know the answer?
Add Answer to:
import random def doTest(operation): ## complete your work here ##    # return True for now...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • : back to classroom run Instructions from your teacher: import random def get_message(user_num, rand_num): Eo von...

    : back to classroom run Instructions from your teacher: import random def get_message(user_num, rand_num): Eo von AwNP Complete the get_message function so if user_num is equal to rand_num, return "You picked the same number as the computer!" if user_num is less than rand_num, return "Your number is smaller than the computer's number." if user_num is greater than rand_num, return "Your number is higher than the computer's number." Comment out the call to main when trying to pass the tests. 11...

  • [Using Python] Create a program that uses import random and while loops to generate one random...

    [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?"

  • This is a python question. from urllib import request import json """ Complete this program that...

    This is a python question. from urllib import request import json """ Complete this program that calculates conversions between US dollars and other currencies. In your main function, start a loop. In the loop, ask the user what currency code they would like to convert to And, how many dollars they want to convert. If you scroll down, you can see an example response with the available 3-letter currency codes. Call the get_exchange_rates() function. This function returns a dictionary with...

  • Hi I need some help in C programing class and I doing one of the exercise...

    Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...

  • This is a python question. Start with this program, import json from urllib import request def...

    This is a python question. Start with this program, import json from urllib import request def main(): to_continue = 'Yes' while to_continue == 'yes' or to_continue == 'Yes': currency_code = input("Enter currency code: ").upper() dollars = int(input("Enter number of dollar you want to convert: ")) # calling the exchange_rates function data = get_exchange_rates() if currency_code in data["rates"].keys(): currency = data["rates"][currency_code] # printing the the currency value by multiplying the dollars amount. print("The value is:", str(currency * dollars)) else: print("Error: the...

  • Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk()...

    Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk() self.main.title("mine sweeper") self.define_widgets() self.mines = random.sample( [(i,j) for i in range(25) for j in range(50) ],self.CustomizeNumberOfMines()) print(self.mines) self.main.mainloop() self.CustomizeNumberOfMines() def define_widgets(self): """ Define a canvas object, populate it with squares and possible texts """ self.canvas = tk.Canvas(self.main, width = 1002, height=502, bg="#f0f0f0") self.canvas.grid(row=0, column=0) self.boxes =...

  • Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a ...

    Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a triangle at depth k given the bottom vertex.    vertex: a tuple (x,y) that gives the coordinates of the bottom vertex. When k=0, vertex is the left bottom vertex for the outside triangle. length: the length of the original outside triangle (the biggest one). k: the depth of the input triangle. As k increases by 1, the triangles shrink to a smaller size. When k=0, the...

  • [Using Python] Create a program to generate one random question, from a list of 5, for...

    [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...

  • ill thumb up do your best python3 import random class CardDeck: class Card: def __init__(self, value):...

    ill thumb up do your best python3 import random class CardDeck: class Card: def __init__(self, value): self.value = value self.next = None def __repr__(self): return "{}".format(self.value) def __init__(self): self.top = None def shuffle(self): card_list = 4 * [x for x in range(2, 12)] + 12 * [10] random.shuffle(card_list) self.top = None for card in card_list: new_card = self.Card(card) new_card.next = self.top self.top = new_card def __repr__(self): curr = self.top out = "" card_list = [] while curr is not None:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT