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
Calculate the average of a set of grades and count
Natasha_Volkova [10]

Answer:

// Scanner class is imported so that the program can can user input

import java.util.Scanner;

// class Solution is defined

public class Solution {

//main method which begin program execution is defined

public static void main(String args[]) {

// Scanner object scan is defined to receive input fromkeyboard

Scanner scan = new Scanner(System.in);

// A prompt is display to the user asking for number of grade

System.out.println("How many grade do you want to enter");

// The user input is assigned to numOfGrade

int numOfGrade = scan.nextInt();

// An array of integer called gradeArray is declared

// it has numOfGrade as length

int[] gradeArray = new int[numOfGrade];

// for-loop that prompt the user to enter grade to fill the gradeArray

for(int i = 0; i < numOfGrade; i++){

System.out.println("Enter a grade: ");

int grade = scan.nextInt();

gradeArray[i] = grade;

}

// sun variable is declared and initialized to 0

int sum = 0;

// numOfFail is declared and initialized to 0

int numOfFail = 0;

// for-loop through the gradeArray that add all element

// it also increase the counter for numOfFail if grade is < 70

for(int j = 0; j < gradeArray.length; j++){

sum += gradeArray[j];

if (gradeArray[j] < 70){

numOfFail++;

}

}

// aveargeGrade is calculated

int averageGrade = (sum / numOfGrade);

// numOfFail is displayed to the user

System.out.println("Number of fail is: " + numOfFail);

// the averageGrade is also displayed.

System.out.println("Average grade is: " + averageGrade);

}

}

Explanation:

The code is well commented and written in Java.

4 0
4 years ago
Please help me solve am wai...​
Ann [662]

Answer:

what the hell

Explanation:

6 0
3 years ago
What is Tone's Core Move call in Titan Fall 2?
AleksandrR [38]

Answer:

Tones Core is called "Salvo Core"

8 0
3 years ago
How many times will an infinite loop repeat?
ExtremeBDS [4]

Answer:

The infinite loop is suppose to go on and on it never ends. My best guess is the third one.

7 0
3 years ago
If you are planning to carry a large balance on your credit card, which of the following credit card features should you look fo
Setler [38]

If you are planning to carry a large balance on your credit card, then you should choose Low APR. Why does it so? Because APR, acronym from Annual Percentage rate will give you guidance on how much the interest you have to pay as an additional charge from your loan.

<h3>Further explanation</h3>

Interested to know more about this answer, let's take a look at our Brainly explanation below.

First, what is APR, APR is the acronym from Annual Percentage Rates. It's an entity from the credit that comes from your credit card. The formula of APR is listed below.

(\frac{\frac{Fees+interest fees}{total loan}}{days of loan}\times 365 ) \times 100 = APR

<h3>Example in Calculation:</h3>

To give a clear view and explanation of what is APR, please take a look at data below. For example, Bob bought a new Macbook pro, that cost him 2500 USD in June 2017. He bought it by his credit card and he need to pay monthly the bill of credit card within 10 months. In middle of 2018, when he finished paid all the bill of his Macbook pro, he realize he paid 150 dollar of the interest. So the calculation of APR from his credit card is.

1. The cost of the product that you pay

             The interest of the payment is 150 dollar.

2. Sum the number and divide by the loan amount

             The percentage 150 dollar divided by 2500 dollar. It gives 0.06

3. Divide them by the day terms of the loan

             The term of the loan is 10 months or 300 days. So It gives 0.06 / 300 = 0.0002

4. Multiply the result to 365 days

              Follow it with 0.002 x 365 = 0.073

5. Multiply by 100 to get the amount in percentage

              It gives 7.3

So the APR is 7.3 %

Below is also some of the reasons why you should not pick the other choice or feature.

<h3>Why the other choices are not relevant:</h3>

B-Low balance transfer fee

Usually, people not using cash in regards to credit card usage. Why does it so, because credit card will give you extra charge to withdraw some money. It also applies to transfer fee, most of the bank provides a free transfer from one account to another account. Therefore low balance transfer is not aligned as the choice to pick a credit card.

C-Lots of credit card rewards

Credit card rewards are a gamification way of the credit card issuer and do you know that in the world only 10% of customers that are using it. It applies to the reward in another service, such as miles award and so on.

D-A large credit limit

The credit limit is entirely the right of the credit card issuer in deciding on how much the credit card should be issued. You can not just pick up the large credit limit without any approval from the institution that approves your credit limit.

Learn more

If you are interested more into this topic, we recommend you too also take a look at the following question.

  • annual percentage rates by monthly: brainly.com/question/8970458
  • annual percentage rate on mortgage : brainly.com/question/1398763
  • how do annual percentage rates: work:brainly.com/question/1361627

<h3>Core curriculum category</h3>

Grade: 12

Subject: Economy

Subchapter: Loan

5 0
4 years ago
Read 2 more answers
Other questions:
  • Write a script that will generate random integers in the range from
    10·1 answer
  • Two columns of a relational table can have the same names. <br> a. True <br> b. False
    15·1 answer
  • Which of the following is the shortcut key combination for pasting copied text?
    11·2 answers
  • Write a function to output an array of ints on a single line. Funtion Should take an array and an array length and return a void
    9·1 answer
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • (Game Design) Creating and manipulating data structures is one of the primary functions of a development environment.
    12·2 answers
  • Theresa is not sure how nondestructive editing can be helpful in her project. Which of these is accurate about nondestructive ed
    8·1 answer
  • You are the network administrator for a small company that implements NAT to access the internet. However, you recently acquired
    13·1 answer
  • An embedded system describes computing technology that has been enclosed in protective shielding for security reasons. True or f
    12·1 answer
  • A ____ attack is much more substantial than a dos attack because of the use of multiple systems to simultaneously attack a singl
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!