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
lubasha [3.4K]
3 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]3 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
Antifreeze is not considered a hazardous waste by the EPA unless it is used or otherwise becomes contaminated.
Ahat [919]

False might be the answer

6 0
3 years ago
Read 2 more answers
List the types of infrared we have
Vlad [161]

Answer: infared types like the sun, sun light, heat lamps, and radiators

6 0
3 years ago
What is the most important for you to choose before you build a network?
olga nikolaevna [1]
Network media is most important
4 0
3 years ago
Identify the four basic categories of hardware in a personal computer system
Pie
The four basic categories are the motherboard, the CPU, the graphics card, and the RAM.
Brainliest pls! thx! :)
5 0
2 years ago
What is the benefit of using a creative commons license?
alukav5142 [94]
It makes things easier for creative people 
3 0
3 years ago
Other questions:
  • String word = “Awesome”;
    9·2 answers
  • What is binary number
    11·1 answer
  • In which step of web design is storyboarding helpful?
    14·1 answer
  • Check my work a(n) ________ reference is an automatically created variable that holds the address of an object and passes it to
    15·1 answer
  • User can use ______ commands to search for and correct words in a document
    13·1 answer
  • What attracts attention and adds spatial depth to a two-dimensional design.
    9·1 answer
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • Question #3
    12·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
  • Multiple Choice
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!