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
inna [77]
3 years ago
11

I'm a beginner in a computer science 1 class. We're learning to code with python. I've been asked to develop code for a simple m

ath quiz. However, my code will no run and I receive the RESTART but no further output. Please advise.
import random

def add(num1, num2):
total_correct = 0

for I in range(2):

num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "+", num2, '=', end = "")
answer = int(input())

if answer == (num1 + num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct

def sub(num1, num2):
total_correct = 0

for I in range(2):

num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "-", num2, "=", end = "")
answer = int(input())

if answer == (num1 - num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct

def mult(num1, num2):
total_correct = 0

for I in range(2):
num1 = random.randint(1, 20)
num2 = random.randint(1,20)
print(num1, "*", num2, "=", end = "")
answer = int(input())

if answer == (num1*num2):
print("correct")
else:
print("incorrect")
return total_correct

def div(num1, num2):
total_correct = 0

for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "//", num2, "=", end = "")
answer = int(input())

if answer == (num1//num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct

def mod(num1,num2):

total_correct = 0

for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "%", num2, "=", end = "")
answer = int(input())

if answer == (num1%num2):
print("correct")
else:
print("incorrect")
return total_correct

again = input()

while again == "yes":
correct_answers=0
correct_answers += add() + sub() + mult() + div() + mod()
print("You've completed the quiz, with a score of", correct_answers, "would you like to try again?", "Type yes to take the quiz again")
again = input()
Computers and Technology
1 answer:
givi [52]3 years ago
6 0

Answer:

1. Your program starts by asking for input, so you would need to type "yes" to begin. If you change your first

   again = input()

line to

   again = "yes"

then the while loop will start.

2. Your functions like add(), sub(), etc are defined to expect two parameters (num1, num2) but in your line that's adding correct_answers, you're calling them with no parameters. Since your functions are setting the values themselves, you can remove the parameters from the function definitions.

Explanation:

You might be interested in
Which of the following devices is used to connect a computer to a network
CaHeK987 [17]
Most are wireless routers, meaning converged devices that include a WAP,router<span>, and often an </span>Ethernet switch<span> in the same device.</span>
3 0
3 years ago
Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
Zielflug [23.3K]
If some files appear dimmed in one of the default folders on your computer, the best course of action would be to A. leave the files as they are.
These files are probably either hidden or system files, which are never meant to be deleted or moved.
8 0
4 years ago
One critique of determining the effectiveness of the psychodynamic perspective is that its theories are too vague to test. t/f
Feliz [49]
TRUE

Psychodynamic theories are usually too vague to allow a clear scientific test. Modest support for central psychodynamic hypotheses has been provided by Empirical studies. Critics have in the past disputed very many aspects of psychoanalysis including whether it is indeed a science or not. However much this is so, psychoanalysis is a great idea in personality that should never be overlooked.






3 0
4 years ago
Read 2 more answers
Hooollaaaa , todos absolutamente todos quieren borrar esta tarea por que no tiene nada que ver con la materias del colegiooo per
Andreas93 [3]

Answer:

JAJAJSJJS XD PERO SI SOY

7 0
3 years ago
Read 2 more answers
. Create an abstract Dollar class with two integer attributes, both of which are non-public (Python programmers - it is understo
aksik [14]

Answer:

Explanation:

The following code is written in Java. It creates the abstract dollar class that has two instance variables for the dollars and the coins that are passed as arguments. The test output can be seen in the picture attached below.

class Dollar {

   int dollars;

   double coin;

   private Dollar(int dollar, int coin) {

       this.dollars = dollar;

       this.coin = Double.valueOf(coin) / 100;

   }

   

}

4 0
3 years ago
Other questions:
  • Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
    11·1 answer
  • Write a program that ask the user to enter air water or Steele and the distance that a sound wave will travel in the medium the
    6·1 answer
  • The main disadvantage of using this device is its negative impact on network performance,resulting from the fact that any incomi
    10·1 answer
  • Anyone got the edmentum computer programming post test answers?
    6·1 answer
  • Rachael has been posting negative comments on several of her peers' social media pages. Which of the six Ps is Rachael abusing?
    15·1 answer
  • How does the system work for this:
    15·2 answers
  • Write a method for the Invitation class that accepts a parameter and uses it to update the address for the event.
    9·1 answer
  • Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number an
    7·1 answer
  • How do i change the default setting in word to no open in dark mode
    8·1 answer
  • Refer to Table 8-4. Consider the data above (in billions of dollars) for an economy: Gross domestic product (in billions of doll
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!