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
Evgen [1.6K]
3 years ago
4

We'd like to create a Keyboard class that takes in an arbitrary number of Buttons and stores these Buttons in a dictionary. The

keys in the dictionary will be ints that represent the position on the Keyboard, and the values will be the respective Button. Fill out the methods in the Keyboard class according to each description, using the doctests as a reference for the behavior of a Keyboard.
Computers and Technology
1 answer:
maksim [4K]3 years ago
3 0

Answer:

class Button:

   """

Explanation:

Represents a single button

   """

   def __init__(self, pos, key):

       """

       Creates a button

       """

       self.pos = pos

       self.key = key

       self.times_pressed = 0

class Keyboard:

   """A Keyboard takes in an arbitrary amount of buttons, and has a

   dictionary of positions as keys, and values as Buttons.

   >>> b1 = Button(0, "H")

   >>> b2 = Button(1, "I")

   >>> k = Keyboard(b1, b2)

   >>> k.buttons[0].key

   'H'

   >>> k.press(1)

   'I'

   >>> k.press(2) #No button at this position

   ''

   >>> k.typing([0, 1])

   'HI'

   >>> k.typing([1, 0])

   'IH'

   >>> b1.times_pressed

   2

   >>> b2.times_pressed

   3

   """

    def __init__(self, *args):

       ________________

       for _________ in ________________:

           ________________

     def press(self, info):

       """Takes in a position of the button pressed, and

       returns that button's output"""

       if ____________________:

           ________________

           ________________

           ________________

           ________________

       ________________

   def typing(self, typing_input):

       """Takes in a list of positions of buttons pressed, and

       returns the total output"""

       ________________

       for ________ in ____________________:

           ________________

       ________________

You might be interested in
What is up with the bots? They are so annoying.
Yuki888 [10]

Answer:

very very very annoying

6 0
3 years ago
Read 2 more answers
When you take a multiple-choice test, you are relying on ________, a means of retrieving information out of your long-term memor
miv72 [106K]

Answer:

recognition

Explanation:

<h2><u>Fill in the blanks</u></h2>

When you take a multiple-choice test, you are relying on <u>recognition</u> , a means of retrieving information out of your long-term memory storage system that helps you choose the correct answer.

4 0
3 years ago
Identify the command on a local desktop CMD that will verify which group policies have been applied to the workstation. SELECT T
fomenos

Answer:

The answer is gpupdate

Explanation:

gpupdate command is used to update Group policies in Windows operating system Domain.

There are different options to use with the gpupdate but one of the most used option is the '/force' which will reapply all policy settings

8 0
3 years ago
As you type your outline, click Demote to move a line of text
polet [3.4K]
<span>C. out one level. i hope this helps</span>
5 0
4 years ago
Read 2 more answers
Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes rece
nydimaria [60]

Answer:

The following fix were made to the program

  1. Change void main() to int main(), then set a return value at the end of the main function;  e.g. return 0
  2. Remove system("pause");  It's not needed
  3. For each of the array, change their lengths to 5 i.e. int votes[5];  string name[5];   and float percent[5];
  4. Lastly, calculate the percentage using: percent[i]=((votes[i]*100.0/total))

Explanation:

(1) void main implies that the main function will not return any value. So, you change it to int main() and then set the return value

(2) There is no need to pause the program, so system.("pause") is not necessary.

(3) The question says there are 5 candidates. So, we set the arrays to accommodate inputs for 5 values

(4) percent array is declared as float; 100.0 will ensure that it calculates the percentage as a float value.

<em>See attachment for updated code</em>

Download cpp
3 0
3 years ago
Other questions:
  • Search engines enable you to
    9·2 answers
  • Why do primitive types have ranges of values? what determines the range of the data type?
    15·1 answer
  • Conduct online research on web authentication and define what it is. Describe different authentication methods
    5·1 answer
  • Why is ipsec considered to be a transparent security protocol?
    6·1 answer
  • Write a program that reads a stream of integers from the console and stores them in an array. The array is then analyzed to comp
    10·1 answer
  • Select the layer of the OSI model that is responsible for reformatting, compressing, and/or encrypting data in a way that the ap
    14·1 answer
  • Finish the code where it says //YOUR CODE HERE
    11·1 answer
  • Complete the GiftCard class shown below. A GiftCard keeps track of the current balance on the card. A gift card starts with a be
    11·1 answer
  • A student wrote a song. Another student posted a video of the song on You Tube, claiming to have written the song. This is most
    15·1 answer
  • you have just finished developing a new application. before putting it on the website for users to download, you want to provide
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!