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
  • Copy the following Python fuction discussed in class into your file: from random import * def...

    Copy the following Python fuction discussed in class into your file: from random import * def makeRandomList(size, bound): a = [] for i in range(size): a.append(randint(0, bound)) return a a. Rename the function sumList as meanList and modify it so that it finds the average of the list. The average is the sum divided by the size (len) of the list. Make sure that the function doesn't give you an error when it is called on an empty list. The...

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

  • import random import turtle def isInScreen(win,turt): leftBound = -win.window_width() / 2 rightBound = win.window_width() / 2...

    import random import turtle def isInScreen(win,turt): leftBound = -win.window_width() / 2 rightBound = win.window_width() / 2 topBound = win.window_height() / 2 bottomBound = -win.window_height() / 2 turtleX = turt.xcor() turtleY = turt.ycor() stillIn = True if turtleX > rightBound or turtleX < leftBound: stillIn = False if turtleY > topBound or turtleY < bottomBound: stillIn = False return stillIn def main(): wn = turtle.Screen() # Define your turtles here june = turtle.Turtle() june.shape('turtle') while isInScreen(wn,june): coin = random.randrange(0, 2) if...

  • PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num...

    PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num + sec_num def additon(first_num, sec_num): return first_num + sec_num; # INTRO print("Hello, \n" "this is an app that helps you practice your math skills while generating 6 sets of lucky numbers") question = input('Are you up for a challenge? [Y/N]') if question == 'n': print('okay, see you later') if question == 'y': print("Let's start!!") # USER NAME VALUE uname = input('what is your user...

  • : 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...

  • Write a program in python that lets the user play the game Rock, Paper, Scissors against...

    Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...

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