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]
4 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]4 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]4 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
The combination of two or more technologies or data feeds into a single, integrated tool is referred to as a _____.
igomit [66]
Mash-up, I believe, is the correct answer.
5 0
3 years ago
Two or more computers connected together is referred to as a(n)
son4ous [18]
Two or more computers connected together is referred to as a network.
So the answer is <span>B. network.</span>
8 0
3 years ago
Privilege escalation is an​
olga55 [171]

Answer:

Privilege escalation is the act of exploiting a bug, design flaw or configuration oversight in an operating system or software application to gain elevated access to resources that are normally protected from an application or user.

Explanation:

give brainiest plzlz

7 0
3 years ago
Why the HTML structure is important to properly written in HTML document
ololo11 [35]

Answer:

A properly written HTML document will not only be readable to the user, but will also convey the structure of the document, the relationship of its content to each other, and allow the user to link to other pages and sites. HTML can do all of this because it's a markup language.

5 0
3 years ago
Read 2 more answers
When you use the onclick()function, it will automatically target which object unless you tell it to do something different?
Paraphin [41]

Answer:

It will target it's parent unless you specify what it should target.

Explanation:

5 0
3 years ago
Other questions:
  • Television has greatly influenced how politicians are perceived via the sound bite and ________ campaigning.
    11·1 answer
  • A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 950
    8·2 answers
  • What are the answers to these questions?​
    11·1 answer
  • Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
    12·1 answer
  • Write a Java program that calculates and prints the monthly pay check for an employee. The net pay is calculated after taking th
    8·1 answer
  • What is a non-example for job application???
    11·1 answer
  • How are hyperlinks created and used within a presentation? Check all that apply. Hyperlinks are set to open another source file.
    7·2 answers
  • Create a while loop to try making a video game turn based battle.
    9·1 answer
  • Alfred works in the human resources department, and he uses a management information system to find applicants' résumés on the w
    7·1 answer
  • Given a list of integers. find the size of the list
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!