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
NemiM [27]
2 years ago
15

Write a program that teaches arithmetic to a young child. The program tests addition and subtraction. In level 1 it tests only a

ddition of numbers less than 10 whose sum is less than 10. In level 2 it tests addition of arbitrary one-digit numbers. In level 3 it tests subtraction of one-digit numbers with a nonnegative difference. Generate random problems and get the player input. The player gets up to two tries per problem. Advance from one level to the next when the player has achieved a score of five points.
Computers and Technology
1 answer:
Natasha2012 [34]2 years ago
7 0

Answer:

import random

class Arithmetics(object):

   trial = 2

   score = 0

   is_end = "Y"

   

   def start(self):

       while self. is_end == "Y":

           self. level1()

           self. level2()

           self. level3()

           self. is_end = input("Do you want to play again? Y/N: "). upper()

       quit()

   def level1(self):

       print("--------------------Level 1--------------------\n\n Addition:")

       for _ in iter(list, 0):

           num1 = random.randint(1,5)

           num2 = random.randint(1,5)

           if self. score == 5:

               print("Congrat! advance to next level\n")

               self. init_()

               break

           print(f"{num1} + {num2}")

           result = int(input("Your answer: "))

           if result == num1 + num2:

               self. increase_score()

           elif self. trial == 0:

               print("Sorry dear, you failed to pass the text.")

               self. end_game()

           else:

               self. trial_reduce()

   def level2(self):

       print("--------------------Level 2--------------------\n\n Addition again:")

       for _ in iter(list, 0):

           num1 = random. randint(1,9)

           num2 = random. randint(1,9)

           if self. score == 5:

               print("Congrat! advance to next level\n")

               self. init_()

               break

           print(f"{num1} + {num2}")

           result = int(input("Your answer: "))

           if result == num1 + num2:

               self. increase_score()

           elif self. trial == 0:

               print("Sorry dear, you failed to pass the text.")

               self. end_game()

           else:

               self. trial_reduce()

   def level3(self):

           print("--------------------Level 3--------------------\n\n Subtraction:")

           for _ in iter(list, 0):

               denum = random. randint(6,9)

               num = random. randint(1,5)

               if self. score == 5:

                   self. init_()

                   self. end_game()

                   break

               print(f"{denum} - {num}")

               result = int(input("Your answer: "))

               if result == denum - num:

                   self. increase_score()

               elif self. trial == 0:

                   print("Sorry dear, you failed to pass the text.")

                   self. end_game()

               else:

                   self. trial_reduce()

   #classmethod

   def trial_reduce(cls):

       cls. trial -= 1

   #classmethod

   def increase_score(cls):

       cls. score += 1

   #classmethod

   def init_(cls):

       cls. trial = 2

       cls. score = 0

   def end_game(self):

       print("Congrats kiddo! You are a math wiz.")

game = Arithmetics()

game. start()

Explanation:

The python class defines the arithmetics class with three-level mathematics for children defined as methods for the class. There are three class methods namely; 'trial_reduce', 'increase_score', and 'init_' with each of them decreasing the trial attribute, increasing the score attribute by one, and initializing the class attributes to its initial state.

The 'end_game' prints a message at the end of the program. Each level is in a loop and counts five times if the answers are correct.

You might be interested in
Suppose you are given a text file. Design a Python3 program to encrypt/decrypt that text file as follows:
Allushta [10]

Answer:

Explanation:

Please find attachment for the Python program

Download docx
7 0
3 years ago
A newspaper publishes a negative editorial on how local politicians are dragging their feet in building a new bridge. Select the
jeka57 [31]
Your answer would be
A. The editorial is data.
I just took this test :)
6 0
3 years ago
Read 2 more answers
What is folded card publishing?​
Alexeev081 [22]

Answer:

Folded card This layout type is for creating greeting cards by printing pages on a sheet and then folding the sheet to make the card. If you choose the Folded card layout, then sheet fold options are displayed. Select an option in the list to specify how you will fold your publication

Explanation:

3 0
2 years ago
Read 2 more answers
Which of these is a primary and secondary source of market research, respectively?
BigorU [14]
B are primary and C are secondary.
3 0
3 years ago
Read 2 more answers
What's the difference between help desk and service desk?
Mekhanik [1.2K]

Answer:

A help desk is considered to be focused on break-fix (like a incident management), where a service desk is there to assist with break-fix and with service requests (requests for new services) and requests for information (ex. “how do I do <u>X</u>?”).

Hope this helps!

3 0
2 years ago
Other questions:
  • Given the commands below, what do they do? for (position = 1 through aList.getLength()/2) { a = aList.getEntry(aList.getLength()
    11·1 answer
  • Will give brainliest!!!!!!!!!!!!
    6·2 answers
  • The master production schedule for Product A shows a need for 30 units, and Product B shows a need of 25 units. To manufacture a
    12·1 answer
  • Imagine a network with two routers that are connected with a point-to-point HDLC serial link. Each router has an Ethernet, with
    9·1 answer
  • g 'write a function that takes as input a list and outs a new list containing all elements from the input
    5·1 answer
  • What would be the total width of the div in the code below?
    11·2 answers
  • Can someone write me a design brief about a stadium​
    12·2 answers
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • which server edition doesn't support any server roles that you would typically use with standard version
    6·1 answer
  • Beginning in cell B21, complete the series of substitution values ranging from $35 to $45 in increments of $2.50 vertically down
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!