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
Describe two steps to find if photos can be legally used
Neporo4naja [7]

Answer:

  1. Check if the image is protected by copyright
  2. Check if the picture has a watermark

Explanation:

Hope it helps

5 0
2 years ago
HURYY PLEASE and please be the right answer!!!with reasoning
ahrayia [7]

Answer:

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

Explanation:

6 0
3 years ago
100 points, PLEASE HELP...To generate numbers between and including -10 to 10 you would use:
Orlov [11]

Answer:

A number line?

6 0
3 years ago
Write a program that asks the user for a CSV of the NYC Open Data Film Permits: There is a sample file for June 2019 film permit
Westkost [7]

Answer:

Before running this program, make sure you have installed pandas module for python.

pip install pandas

import pandas as pd

import numpy as np

csv_file = input("Enter CSV File Name : ")

df = pd.read_csv(csv_file)

count_row = df.shape[0]

print("There were %d Film Permits in Total." %(count_row))

borough_count = df['Borough'].value_counts()

print(borough_count)

location_count = df['ParkingHeld'].value_counts().head(5)

print(location_count)

Explanation:

4 0
3 years ago
Read 2 more answers
Briefly describe the concept of network topology change and explain how these can be dealt with using Routing Information Protoc
Natasha2012 [34]

Answer: network topology is the arrangement of nodes which includes routers and switches so that enables connection between the server and the client.

however due to times when there is huge traffic in the nodes there needs to be an optimal path for the exchange of information which is accomplished by different routing protocols.

Explanation:

Routing Information Protocol(RIP) is one such protocol which enables to route packets from the source to the destination having the least possible traffic along its path. There are two sets of routing algorithm which are

1. Static routing protocols

2. Dynamic routing protocols.

The difference between the two is that dynamic routing protocols helps to construct the routing tables dynamically as compared to static routing.

RIP is a type of dynamic routing whereby it sends the contents of its routing table the adjacent routers every 30 seconds and whenever a route is discarded from the routing table it is marked as unusable.

RIp is supported by almost all routers and also supports load balancing which is one of it advantages.

8 0
3 years ago
Other questions:
  • When computer manufacturers overcame the enormous 13,000 Chinese character barrier by creating a workable keyboard through voice
    15·1 answer
  • What is an Odometer (Driver's Ed)
    7·2 answers
  • Laura has many online accounts discuss the privacy concerns associated with individuals use of the Internet
    15·1 answer
  • Which type of network cable is commonly used to connect office computers to the local network
    13·1 answer
  • To light up an LED, you need to connect the cathode leg to one of the Digital Pins and connect the Anode leg to the ……………. on th
    13·1 answer
  • Which of the following bit value represent -5 in two's complement notation?
    5·1 answer
  • Computing is the provision of IT services on demand.
    9·1 answer
  • Why do we use if statements?
    9·1 answer
  • How to make classs constructer java.
    14·1 answer
  • An independent penetration testing company is invited to test a company's legacy banking application developed for Android phone
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!