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
ludmilkaskok [199]
3 years ago
11

Create a function generateString(char, val) that returns a string with val number of char characters concatenated together. For

example generateString('a', 7) will return aaaaaaa.
Computers and Technology
2 answers:
Grace [21]3 years ago
8 0

Answer:

The solution code is written in Python.

  1. def generateString(char, val):
  2.    output = ""
  3.    for i in range(val):
  4.        output += char
  5.    
  6.    return output  
  7. print(generateString('a', 7))

Explanation:

Firstly, let's create a function <em>generateString()</em> that take two input arguments, <em>char</em> and<em> val.</em>

To generate a string with <em>val </em>number of <em>char</em>, we need a string variable, <em>output,</em> to hold the string value. Let's initialize the <em>output</em> with an empty string (Line 2)

Next, we can create a for loop that will repeat the loop for <em>val</em> number of time (using the <em>range() </em>method) and keep adding the same <em>char</em> to the <em>output</em> string (Line 5).

At last return the <em>output</em> string (Line 7).

WARRIOR [948]3 years ago
5 0

I have write a very simple code for you in python and i hope it will help you a lot.


def generateString(char, val):

   print(char * val)

Explanation:

This is how you can create your function in python and this function will give you the desired output.


How to Call a function:

generateString('a',12)

this is how you can call the function to get output.

I hope you get the idea.



You might be interested in
What is sum after the following loop terminates? int sum = 0; int item = 0; do { item ; sum = item; if (sum &gt; 4) break; } whi
irinina [24]
Int sum = 0;
int item = 0;
do
{
    item;
    sum = item;
    if (sum > 4)
        break;
} while (item < 5);


You will generate a compile error, as having (item;) as a statement on its own is invalid.
8 0
3 years ago
Read 2 more answers
Is it more costly to Andrew to go to graduate business school full time or part time if the tuition is the same for each? A. Par
andrezito [222]

Answer:

A. Part time

Explanation:

Since tuition is the same whether he goes part time or full time, in the long run he will end up paying tuition a greater number of times if he is a part time student.

4 0
3 years ago
Read 2 more answers
During active listening, which response is NOT an example of providing feedback to the speaker to show that you understand his o
MaRussiya [10]

Answer:

The answer is D.

Explanation:

They/you are asking the speaker to clarify what they just said.

6 0
3 years ago
This type of technology typically does NOT come with a keyboard or mouse for input.
anyanavicka [17]
The answer is C) tablet. You use the touch screen keyboard for that.
4 0
3 years ago
Read 2 more answers
Three types of common program errors are syntax, runtime, and logic. (5 points)
adoni [48]

Answer:

True

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which actions should be taken so that transitions proceed automatically? Check all that apply.
    12·2 answers
  • ​For complex models, analysts can choose computer-based modeling tools that use _____, which includes standard shapes and symbol
    10·1 answer
  • Computer with a domain name is called a
    7·1 answer
  • Big data refers to huge collections of data that are difficult to process, analyze, and manage using conventional data tools. It
    13·1 answer
  • Which type of microphone uses two metal plates?
    7·1 answer
  • ______The statement #include &lt; math.h &gt; defines the name of the current program you are writing as "math". (T/F)
    10·2 answers
  • What is the code name for the 12 engineers who developed the ibm pc?
    8·1 answer
  • Many of the first photographers were actullay scientists and inventors
    11·1 answer
  • Lucy has to move data from column A to column N in a worksheet. Which keys should she select to move data in the same worksheet?
    9·2 answers
  • Fill in the blanks : To store 3 character a computer occupies...................bytes memory space​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!