Computers and Technology
Computers and Technology, 02.12.2020 21:50, peno211

Can someone translate this is Python language PLEASE! # A program to practice adding and multiplying.
# Initialize the number lists.
# Ask the user whether to practice adding or multiplying.
# Generate number problems and ask for an answer.
# Compare the user's answer to the correct answer.
# Keep score.
# Tell the user how they did.

# A program to practice adding and multiplying.
# Initialize the number lists.
numA = [4, 1, 6, 10, 2, 3, 7, 9, 11, 12, 5, 8 ]
numB = [2, 12, 10, 11, 1, 3, 7, 9, 4, 8, 5, 6]
numberFacts = len(numA)

# Ask the user whether to practice adding or multiplying.
print("You can add or multiply.")
mode = input("Enter A for add or M for multiply: ")
mode = mode. lower()

# Generate number problems and ask for an answer.
if mode == 'm':
for n in range(numberFacts):
print("What is", numA[n], "times" , numB[n], "?")
product = numA[n] * numB[n]
answer = input(" ")
try:
answer = float(answer)
except ValueError:
print("You did not enter a number. Try again on a new problem.")
print("")
continue
if answer == product:
print("Correct! Way to go!")
else:
print("Sorry, the answer is", product, ".")
print("")
elif mode == 'a':
for n in range(numberFacts):
print("What is", numA[n], "plus" , numB[n], "?")
product = numA[n] + numB[n]
answer = input(" ")
try:
answer = float(answer)
except ValueError:
print("You did not enter a number. Try again on a new problem.")
print("")
continue
if answer == product:
print("Amazing!")
else:
print("Sorry, the answer is", product, ".")
print("")
else:
print("You did not make a valid choice. You needed to choose A or M.")

# Below is the pseudocode before code was added

# Compare the user's answer to the correct answer.
# Keep score.
# Tell the user how they did.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, danthehero56
Which of the following is true of operations within a spreadsheet program’s built-in functions? a. operations within parentheses, then multiplication and division, and then addition and subtraction are computed. b. operations within parentheses, then addition and subtraction, and then multiplication and division are computed. c. multiplication and division, then addition and subtraction, and then operations within parentheses are computed. d. addition and subtraction, then multiplication and division, and then operations within parentheses are computed
Answers: 2
image
Computers and Technology, 24.06.2019 00:20, talyku843
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
image
Computers and Technology, 24.06.2019 13:00, NycLife
Why should you evaluate trends when thinking about a career path?
Answers: 1
image
Computers and Technology, 24.06.2019 21:40, imamador6396
Which of these is not a type of socket? aga (alternating grid array) pga (pin grid array) spga (staggered pin grid array) lga (land grid array)
Answers: 1
Do you know the correct answer?
Can someone translate this is Python language PLEASE! # A program to practice adding and multiplyin...

Questions in other subjects:

Konu
Mathematics, 18.03.2021 02:00