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
DIRECTIONS: Organize your desktop. Name the 5 folders based on the files given below. Organize your own desktop by sorting the g
dem82 [27]

Answer: Music, Documents, PowerPoints, Pictures/Videos, Audios

6 0
2 years ago
Which of the following electronic payments is ideal for micropayments?
timama [110]

Answer:

B. smart cards

Explanation:

3 0
2 years ago
Read 2 more answers
Identifying the problem is crucial when trying to solve a problem. There are several techniques that you can use to aide you in
erica [24]
Consensus Building is NOT a technique that you can use to help you in identifying a problem.
8 0
3 years ago
Which of these skills are used in game design?
olasank [31]

Answer:

I think the answer is Writing but am not sure

8 0
2 years ago
You currently are IT support for Richman Investments, a brokerage firm that employs 20 brokers. Each broker has their own client
lions [1.4K]

Answer:

Use the System Restore tool to restore the affected computers back to a point before the problematic updates. To forestall issues with problematic updates, one needs to install and configure the Windows Server Update Services (WSUS) Server role.

Explanation:

Windows Update creates a restore point prior to applying any updates and this makes it easier to rollback any problematic updates using the aptly named System Restore utility.  System Restore can be launched either from within Windows or during startup depending on whether the computer can be booted  or not.

One solution to preventing this kind of problem is the implementation of a Windows Server role, the Windows Server Update Services (WSUS), which helps administrators to safely manage Windows Update for clients within its network. WSUS allows administrators to test updates for issues and approve them before they are available for deployment to clients.

4 0
2 years ago
Other questions:
  • Consider the concept of cultural lag. Identify two American values that are “lagging.” What are three norms that are lagging? Ho
    11·1 answer
  • Which option marks all modification made within a document? Review Comment Track Changes Balloons
    15·2 answers
  • Which one of the following is a correct declaration for a method named passAList that has as arguments an array list myList of s
    8·1 answer
  • What does the internet engineering task force (IEFT) do?
    5·1 answer
  • Select the correct answer.
    6·1 answer
  • 2. Which property is used for hiding text of the textbox?
    14·1 answer
  • The advancements in which of the following technologies has most changed the American job market in recent years?
    14·2 answers
  • Ethan is coding in Python and trying to add a set of numbers including both floats and integers. What should he do to make sure
    12·1 answer
  • Identify and explain 4 traditional (old ways) marketing approaches used by University uses in reaching
    7·1 answer
  • What represents a user’s specific preferences?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!