Question

In: Computer Science

Use Python 3, please type. Write a Python 3 program which is an arithmetic quiz for...

Use Python 3, please type.

Write a Python 3 program which is an arithmetic quiz for children. The program asks the user to calculate the multiplication of two numbers generated at random in your code. The numbers should be in the range 1 through 10. User input is shown in bold black font in the example below.

You will need to use random numbers. You should type the recommended comments at the top of your code and include three test runs in the comments.

Example program run:

Please enter the result of multiplying 6 x 7 :

42

Correct.

Another question? (y/n):

y

Please enter the result of multiplying 2 x 7 :

13

Incorrect.

Another question? (y/n):

n

You scored 1 out of 2. That is 50% and letter grade": P

Solutions

Expert Solution

import random

correct = 0
total = 0
while True:
    n1 = random.randint(1, 10)
    n2 = random.randint(1, 10)
    answer = int(input("Please enter the result of multiplying {} x {} :\n".format(n1, n2)))
    if answer == n1 * n2:
        print("Correct.")
        correct += 1
    else:
        print("Incorrect.")
    total += 1
    choice = input("Another question? (y/n):\n")
    if choice == 'n':
        break

grade = (correct * 100) / total
if grade >= 90:
    letter_grade = 'A'
elif grade >= 80:
    letter_grade = 'B'
elif grade >= 70:
    letter_grade = 'C'
elif grade >= 60:
    letter_grade = 'D'
else:
    letter_grade = 'F'
print("You scored {} out of {}. That is {}% and letter grade: {}".format(correct, total, grade, letter_grade))


Related Solutions

USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass...
USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass Index (BMI) of a person if they enter their weight and their height to your program. Check out the formula here: http://www.freebmicalculator.net/calculate-bmi.php Your program should first print "Body Mass Index Calculator" The program will then ask the user if they want to enter Metric Units or English Units. Using the appropriate formula (see link above) calculate their BMI. Depending on their BMI show their...
In C++ Write a program that will conduct a quiz consists of 10 arithmetic questions and...
In C++ Write a program that will conduct a quiz consists of 10 arithmetic questions and display the final score as ‘Your score in the quiz is X’ with a response message in the next line. A response message will be as follows based on the student’s performance: a. Number of correct answers >= 9: Excellent, your are passed with ‘A’ grade! b. Number of correct answers >= 7, but less than 9: Very Good, you are passed with ‘B’...
Please write in python Use modular design to write a program that asks the user to...
Please write in python Use modular design to write a program that asks the user to enter his or her weight and the name of a planet. The program then outputs how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet. PLANET CONVERSION FACTOR Mercury 0.4155 Venus 0.8975 Earth 1.0000 Moon 0.1660 Mars 0.3507 Jupiter 2.5374 Saturn 1.0677 Uranus 0.8947 Neptune 1.1794 Pluto 0.0899 The...
I need to write an interpreter for arithmetic expressions in Python. This program receives an input...
I need to write an interpreter for arithmetic expressions in Python. This program receives an input string with an arithmetic expression and does: 1. prints a ">>>" as if it was a terminal 2. lets us allocate a variable to a a numeric value (as "a = 3") then it stores {'a':3} to a dictionary memory 3. whenever it receives an expression or input, transform it to postfix notation and print it (even when allocating variables) 4. it is able...
write a “quiz” program on a topic, about which you are knowledgeable. this quiz can be...
write a “quiz” program on a topic, about which you are knowledgeable. this quiz can be work related, general knowledge or any set of questions where there is a specific answer. ignore questions where long descriptions or general answers needed. the program should display the questions, one at a time, and possible answers, and accept an answer from the user. if the answer is correct, the program should go on to the next question. if it is incorrect, store the...
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers...
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers labelled A, B, C and D.    After displaying the first question and the 4 possible answers, the user is asked to enter their choice. If their choice is correct, add 1 to the score, then display the next question and its 4 possible answers. At the end of the quiz, display their score out of 5, their score as a percentage, and if...
Please use the python 3.7 for this assigments Q1 Write a program that accepts the lengths...
Please use the python 3.7 for this assigments Q1 Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is an equilateral triangle. Q2 Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square...
Please use Python 3 3). Write a function that writes a series of random numbers to...
Please use Python 3 3). Write a function that writes a series of random numbers to a text file named ‘random_number.txt’. Each random number should be in the range of 1 through 500. The function should let the user specify how many random numbers the file will hold. Then write another function that reads the random numbers from the ‘random_number.txt’ file, displays the numbers, and then displays the total of the numbers and the number of random numbers read from...
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
Develop a python program that prompts the user to take up the quiz (which has choices)...
Develop a python program that prompts the user to take up the quiz (which has choices) with limited attempts and limited time. Suppose if the user answered wrong then they have to get numer of attempts(limited) Quiz should have questions on General knowldge & multiple choices for those questions
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT