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
lubasha [3.4K]
2 years ago
7

Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik

es to simulate. It should return a string containing that many characters, each one obtained from simulating a key strike by the monkey.
Computers and Technology
1 answer:
Furkat [3]2 years ago
7 0

Answer:

The solution code is written in Python 3

  1. import random
  2. import string
  3. def simulate_several_key_strikes(l):
  4.    char_set = string.ascii_lowercase
  5.    return ''.join(random.choice(char_set) for i in range(l))
  6. print (simulate_several_key_strikes(10))

Explanation:

The program is aimed to generate random characters and the number of characters generated is dependent on user input. Hence, we will need to import the random module (Line 1). We also import string module so that we can make use of its associated method to generate English letters (Line 2)

Next, we create the function simulate_several_key_strikes that takes one single parameter, l, as input. Within the function body, we use ascii_lowercase method to generate the lowercase letter set and assign it to char_set variable (Line 5). We use random.choice method to randomly pick one of the letter in char_set and join it with an empty string (Line 6). Please note there is a for-loop that will repeatedly generate l-number of character and eventually return it as output.

We test the function by passing 10 as input parameter and we shall get a sample output as follows:

xuiczuskoj

You might be interested in
Suppose Dave drops a watermelon off a high bridge and lets it fall until it hits the water. If we neglect air resistance, then t
MaRussiya [10]

Answer:

#include <bits/stdc++.h>

using namespace std;

// driver function

int main()

{

   // variables

  const double g = 9.8;

int sec;

double height;

int    t  = 0;    

double d = 0;    

bool   flag = false;  

// ask to enter time

cout << "Please enter the time of fall(in seconds):";

// read time

cin >> sec;

//ask to enter height

cout << "Please enter the height (in meters):";

//read height

cin >> height;

cout << '\n'

     << "Time(seconds)   Distance(meters)\n"

        "********************************\n";

// calculate height after each seconds

while ( t <= sec) {

cout << setw(23) << left << t

      << setw(24) << left << d << '\n';

// if input height is less

 if ( d > height ) {

  flag = true;

 }

// increament the time

 t += 1;

// find distance

 d = 0.5 * g * (t) * (t);

}

cout << '\n';

// if input height is less then print the Warning

if ( flag ) {

 cout << "Warning - Bad Data: The distance fallen exceeds the height"

         " of the bridge.\n";

}

return 0;

}

Explanation:

Read the time in seconds from user and assign it to "sec" then read height and  assign it to "height".After this find the distance after each second.If the input height is less than the distance at any second, it will print a Warning message. otherwise it will print the distance after each second.

Output:

Please enter the time of fall(in seconds):11                                                                              

Please enter the height (in meters):1111                                                                                  

                                                                                                                         

Time(seconds)   Distance(meters)                                                                                          

********************************                                                                                          

0                      0                                                                                                  

1                      4.9                                                                                                

2                      19.6                                                                                                

3                      44.1                                                                                                

4                      78.4                                                                                                

5                      122.5                                                                                              

6                      176.4                                                                                              

7                      240.1                                                                                              

8                      313.6                                                                                              

9                      396.9                                                                                              

10                     490                                                                                                

11                     592.9  

5 0
2 years ago
James has created some artwork portraying life on a different planet. He wants to show a world where everything is beautiful and
PIT_PIT [208]
What are the answer choices if so can you please post it with answer choices ?
5 0
2 years ago
Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
blondinia [14]

Answer:

1) Nate open his template first and clicks the tab on the ribbon

2) Then, he clicks the dialog box that appears

3) He chooses Templates from the menu

4) Clicks Go to clicks the Organizer button

5) Then he clicks copy

6) Next he clicks on the left side to the backstage view

7) Finally, he selects the document that includes the style he wants to transfer to the normal template

Explanation:

I hope this helps

5 0
2 years ago
Darcy is creating an instructional manual for her employees. She entered the text in a word processing program and wants to impo
NeX [460]
When Darcy finish creating the instructional manual for her employees, she can copy paste her content from the word processing program to DTP by :
a) Press Ctrl a to select all the content from the word processing program;
b) Press Ctrl c to copy everything from the word processing program;
c) open DTP
d) Press Ctrl v to paste everything, word by word, page by page from the word processing program to DTP.
5 0
2 years ago
suppose that you have been given the task of writing an unloader - that is, a piece of software that can take the image of a pro
Brums [2.3K]
............;(&;&;$;!:$:!;$;8;$;$;;$;&8;$;$;$;$;$;$;$;$;$;
8 0
2 years ago
Other questions:
  • Mary can view the thumbnails of her presentation slides when she is creating the slides. Which element of the program’s interfac
    5·2 answers
  • Carefully choosing from a set of alternatives to accomplish an objective is known as? A. Independence B. Decision making C. Netw
    9·2 answers
  • How many frequencies does a full-duplex qam-64 modem use?
    8·2 answers
  • Which of the following is not one of the four methods for classifying the various instances of malware by using the primary trai
    9·1 answer
  • A database design where certain data entities are combined, summary totals are carried in the data records rather than calculate
    5·1 answer
  • Which one of the following characteristics or skills of a ScrumMaster are closelyaligned with coaching?Select one:
    5·1 answer
  • #Remember that Fibonacci's sequence is a sequence of numbers
    14·1 answer
  • He volume of a sphere is 4/3πr3, where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called pr
    5·1 answer
  • Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    14·1 answer
  • Write a program that uses the Purchase class in 5.13. Set the prices to the following: Oranges: 10 for $2.99 Eggs: 12 for $1.69
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!