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
A company has a popular gaming platform running on AWS. The application is sensitive to latency because latency can impact the u
AysviL [449]
Yetwywywywywywyyw would
8 0
2 years ago
The type of cover letter written in response to a posted job opening
amm1812

Answer:

C

Explanation:

I don't have one but I hope you get an A.

I hope this helped

                     

4 0
3 years ago
Relieved to have survived ,henry rolled off the rink________.giving alex a grateful look
Marina86 [1]

Answer:

simultaneously might be the answer

8 0
2 years ago
Interactive sites where users write about personal topics and comment to a threaded discussion are called A. networking sites. B
Viefleur [7K]

The answer is definitely C: Blogs.

Blog is somewhat very similar to a website. It is sort of a journal that is mostly maintained by one person, the blogger. They are updated regularly and can contain information related to a specific topic. In most cases, blogs are used as dairy diaries about politics, people’s personal lives, or social commentaries. They give you, as a blogger, opportunities to interact with your visitors while promoting your products.

3 0
3 years ago
Read 2 more answers
Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
Charra [1.4K]
<span>Storage costs of magnetic tape are much lower than semiconductor storage (chip storage), but they take longer to access because they are not on-board the system and have to be added manually. Chip memory, on the other hand, can be used as primary storage for a system even with a higher cost because it's typically directly connected to the system board and is much more easily accessible by the system.</span>
8 0
3 years ago
Other questions:
  • The following declaration appears in a program: short totalPay, basePay = 500, bonus = 1000; The following statement appears in
    9·1 answer
  • When changing passwords, at least how many characters must be changed from the previous password?
    15·1 answer
  • harry is analyzing inbound network traffic and notices a tcp packet that has the FIN,PSH, and URG flags set at the same time. wh
    8·1 answer
  • 5. RAM IS YOUR SYSTEM’S-
    14·2 answers
  • How to code on python
    8·2 answers
  • Find the number of times a value appears in a list, and create a new list that contains the index positions where the value occu
    6·1 answer
  • If I use google incognito mode or a throwaway google account can my search history be tracked by Microsoft parental controls?
    7·1 answer
  • Evie clicks through her presentation slides and realizes they all have transition effects coming from the same location, from th
    13·1 answer
  • Specific keys that each finger is responsible for typing is called A. ergonomics B. Touch typing C. Key reaches D. Posture
    8·1 answer
  • Complete the sentence about bias and equity.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!