Computers and Technology, 17.10.2020 07:01 helpmeplz33
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 math 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()
Answers: 2
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
Answers: 3
Computers and Technology, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
Computers and Technology, 23.06.2019 06:00
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
I'm a beginner in a computer science 1 class. We're learning to code with python. I've been asked to...
Mathematics, 31.10.2020 17:50
English, 31.10.2020 17:50
English, 31.10.2020 17:50
History, 31.10.2020 17:50
History, 31.10.2020 17:50
Biology, 31.10.2020 17:50
Social Studies, 31.10.2020 17:50
Arts, 31.10.2020 18:00
Mathematics, 31.10.2020 18:00