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]
3 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]3 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
Differences between iphone 6 and 6s
amid [387]
I phone 6s is bigger than a regular iphone and iphone 6s's dosn't bend like iphone 6
4 0
4 years ago
With the Linux operating system, its open source design means it can be used, modified and ______
nadya68 [22]

Answer:

distributed.

Explanation:

Because Linux is released under an open source license, which prevents restrictions on the use of the software, anyone can run, study, modify, and redistribute the source code, or even sell copies of their modified code, as long as they do so under the same license.

3 0
3 years ago
If you enter a command and want to terminate its execution before it is finished, you can press ____ to do so.
sertanlavr [38]
If you mean on the phone you can press the home button. if you mean on the computer you could press esc
5 0
3 years ago
Read 2 more answers
What technology process would help you access files at all times?
sveta [45]

Answer:

F and H

Explanation:

Cloud stores and saves all your information and a hard drive you can carry around

If anyone who knows more about this can correct me or say that im correct that would be of much help.

8 0
4 years ago
1. In your own words, describe the purpose of a for a loop.
Talja [164]

A for loop is typically used in situations where the number of cycles for the loop is known before hand. One thing that uses for loops is video rendering software, it uses it to render each file and allocate each rendered file to its specified destination.

5 0
3 years ago
Other questions:
  • Jacob is a website designer. Whenever his company takes on a new project, Jacob takes the initiative and comes up with ideas and
    12·1 answer
  • 2) Describe how data becomes knowledge.​
    10·1 answer
  • 6.6 Write a function named timesTen. The function should have an integer parameter named number. When timesTen is called, it sho
    7·1 answer
  • Match the parts of a CPU to their fuctions
    8·1 answer
  • BRAINLIEST AND A LOT OF PTS Which line of code will only allow a symbol to be stored in a variable?
    12·2 answers
  • Memory is the place of the computer where data and instructions are stored either permanently or temporarily. True or false.​
    11·1 answer
  • ¿Cómo afecta negativamente a las relaciones familiares el uso de la tecnología?
    7·1 answer
  • When you type in text in an image in a photo-editing software, where is it created?
    8·1 answer
  • You have just purchased a new Dell PowerEdge R820 Rack Server. The server is equipped with four Xeon E5-4650 CPUs, 128 GB of RAM
    8·1 answer
  • Developing algorithms using psuedocode
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!