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
Which hexadecimal number is equivalent to the decimal number 11?
Elina [12.6K]
1011, hope that helps.
8 0
3 years ago
Suggest three ways in which celebrating an occasion influences food choices?
Basile [38]

Celebrating influences food in more than 1 way
6 0
3 years ago
Read 2 more answers
Write a recursive method in pseudo code that returns the number of 1's in the binary representation of n. use the fact that this
Deffense [45]
Int count(int num)

if   num==0   return  0;
return   (n&1)+count (n/2)


4 0
3 years ago
Electricity was seen as a mysterious force and began to creat a stir when people called​
atroni [7]

This isn't related to computers and when you look it up all it comes up with a Stars Wars.

3 0
3 years ago
I am confused about joins in sql.
WITCHER [35]

Answer:

eeee3eeeeeeeeeeeeeeeeeeee

5 0
4 years ago
Read 2 more answers
Other questions:
  • An increase in Consumption will ___________ in the Classical Model of Aggregate Demand.
    13·1 answer
  • #We've started a recursive function below called #measure_string that should take in one string parameter, #myStr, and returns i
    5·1 answer
  • What are the prime factorizations of 52 and 77? a. b.
    5·1 answer
  • python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T
    12·1 answer
  • What is the use of jacquard loom
    13·2 answers
  • What symbol indicates that material has been copyrighted?
    8·2 answers
  • How to write my name in binary code ? Rivas
    7·2 answers
  • The ______ Works on a single variable or constant. *​
    8·1 answer
  • Complete the following sentence by choosing the best answer from the options listed below.
    11·2 answers
  • What will be the result from running the following program?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!