answer.
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]
2 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]2 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
Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a Vend
ivann1987 [24]

Answer:

In C++:

#include <iostream>

using namespace std;

class VendingMachine {

 public:

   int initial = 20;};

int main() {

 VendingMachine myMachine;

   int purchase, restock;

   cout<<"Purchase: ";  cin>>purchase;

   cout<<"Restock: ";  cin>>restock;

   myMachine.initial-=(purchase-restock);

   cout << "Inventory: "<<myMachine.initial<<" bottles";  

   return 0;}

Explanation:

This question is incomplete, as the original source file is not given; so, I write another from scratch.

This creates the VendingMachine class

class VendingMachine {

This represents the access specifier

 public:

This initializes the inventory to 20

   int initial = 20;};

The main begins here

int main() {

This creates the object of the VendingMachine class

 VendingMachine myMachine;

This declares the purchase and the restock

   int purchase, restock;

This gets input for purchase

   cout<<"Purchase: ";  cin>>purchase;

This gets input for restock

   cout<<"Restock: ";  cin>>restock;

This calculates the new inventory

   myMachine.initial-=(purchase-restock);

This prints the new inventory

   cout << "Inventory: "<<myMachine.initial<<" bottles";  

   return 0;}

8 0
2 years ago
Dante has a worksheet shared with multiple users. He would like the ability to approve or reject changes that are made. Which fe
Gemiola [76]

Answer:

Data Consolidation.

Explanation:

7 0
2 years ago
1.1.5 practice: analyzing business culture
USPshnik [31]

Answer:

 

A positive culture is an advantage when changes need to be made in the company. Making organisational changes and maintaining a positive culture a mutually complementary rather than mutually exclusive.

In a positive culture environment, people are happy and feel valued. When people feel happy and valued, it makes it easy for management to garner their buy-in cooperation when changes need to be made within the business.

In a culture that is negative, people don't feel valued and as such are always after their own interest rather than that of the company. There is also a tendency to always be on the defensive side of any change that is about to come looking out for one's self rather than what is best for the collective good. In this case, staff are much likely to sabotage new initiatives and changes rather than work to actuate them.

The obverse is true for a business with a positive culture.

Cheers!

3 0
2 years ago
Steps in creating a folder
enyata [817]
Right click computer screen and press new folder?
or add paper to rings in the physical folder<span />
8 0
2 years ago
A chess-playing computer program that routinely calculates all possible outcomes of all possible game moves best illustrates pro
Evgesh-ka [11]
<span>A chess-playing computer program that routinely calculates all possible outcomes of all possible game moves best illustrates problem solving by means of </span>brute force.
5 0
2 years ago
Other questions:
  • Information gets from sensory memory to short-term memory through the process of _________.
    13·1 answer
  • f the copyright date on the homepage is more than 1 year old, the website should always be considered unmaintained
    8·1 answer
  • Kyle took a photograph of his sister, but he later noticed that his lens was marginally out of focus. Which tool can he use to i
    15·1 answer
  • Claire writes a letter to her grandmother, in which she describes an amusement park she visited last week. She adds pictures of
    11·1 answer
  • a. STOP: What is a technology habit you practice today that you now realize will not help you to be successful? Explain why it’s
    13·2 answers
  • PC’s &amp; More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
    14·1 answer
  • 9.6 Code Practice: Question 1
    9·1 answer
  • Nathan would like to save his PowerPoint presentation as a video that can be replayed easily on any device at full quality. Whic
    14·1 answer
  • Disk scheduling algorithms in operating systems consider only seek distances, because Select one: a. modern disks do not disclos
    13·1 answer
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!