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
Yakvenalex [24]
3 years ago
6

Write a function called getChar that has no function inputs, but takes in two character inputs from the user (in1 and in2) and o

utputs them to the function that calls them (The function must use input validation to make sure it is a character - Hint: use the length() function). Write another function called chars2string that takes in two character function inputs and combines them into one string that repeats each character 5 times and returns the joined string (as function output). Call both functions in a main function.

Computers and Technology
1 answer:
bearhunter [10]3 years ago
3 0

Answer:

def getChar():

   while True:

       in1 = input('Enter first char: ')

       try:

           if len(in1) != 1:

               raise

           else:

               in2 = input('Enter second char: ')

               if len(in2) != 1:

                   raise

               else:

                   break

       except:

           print('Enter just one character')

   return in1, in2

def chars2string(in1,in2):

   print(in1*5 + in2*5)

def main():

   ls = getChar()

   in1 = ls[0]

   in2 = ls[1]

   chars2string(in1, in2)

if __name__ == '__main__':

   main()

Explanation:

The programming language used is python 3.

The script first defines a function getChar and makes use of a while loop in combination with try and except blocks and IF statements, the code ensures that both inputs that are entered by the user after the prompt are 1 in length. i.e. Just one character. This function returns the two characters that were entered.

The second function that is defined is chars2string this function takes two arguments, It repeats each argument five times and returns a joined string.

Finally, the main function is defined and it calls the getChar function  first, the values that are returned by this function is assigned to two variables, that is then passed on to the chars2string function. The main function is called and the Joined string is printed to the screen.

You might be interested in
A technician is troubleshooting a Windows system in which an application works properly when the computer is booted in Safe Mode
sweet-ann [11.9K]

Answer:

yoooo nba BAD BAD

Explanation:

3 0
3 years ago
__________ refers to excavating the sides of an excavation to form one or a series of horizontal levels or steps, usually with v
Nutka1998 [239]

The answer is Benching.

Benching and sloping are methods used to protect employees working in excavations from cave–ins. Benches are cuts in the slope that provides protection by removing material at an angle to its floor. They give the slope a stair-step appearance with emphasis on the angles; the flatter the angle, the more the protection. Benches are split into two groups: simple and multiple.

6 0
3 years ago
Read 2 more answers
What is the working principle of computer?
ankoles [38]
The CPU is the working principle
8 0
3 years ago
Troy, an aspiring screenwriter, aspires to work with a famous director known for his philanthropic work. Troy gets an appointmen
kicyunya [14]

Troy should include a short overview of the story that his video will tell and why he wants to tell it (or what the video will be about and why). It should also include the target audience, and where the video will be published.

7 0
3 years ago
Greg is writing a report on becoming an advertising and promotions manager. Complete the report by correctly filling in the miss
zzz [600]

Since Greg wants to become an advertising and promotions manager, he needs to at least gain a (B) bachelor’s degree level of education, since generally, this educational background is expected from individuals who wishes to work in an entry-level position in the field of advertising.

One of the skills that he also needs to develop is (C) communication skills, because he would have to be able to communicate in both written and spoken to develop the advertisements according to the client’s desires.

8 0
3 years ago
Other questions:
  • A client accessing a network share folder has authenticated into the system and has full access rights to a folder share. But af
    11·1 answer
  • Is it possible to learn java s. and c# at the same time? if so I need help who can assist me.
    5·1 answer
  • How can i become an expert in computer and technology?
    15·2 answers
  • How do you repair a USB?
    15·2 answers
  • How can volunteering yo help plan fundraiser for your team or club be a way to develop your strengths?
    13·1 answer
  • Match the following technologies with their applications.
    11·1 answer
  • The World Health Organization decided that addiction to video games is considered a mental health disorder. Do you agree or disa
    10·1 answer
  • 100 POINTS NEED THIS BEFORE 11:59 TODAY!!!!!!!!!!!!!!!
    8·1 answer
  • RTOS stands for ______ Time Operating System.
    11·1 answer
  • 2. Explain the difference between a JMP instruction and CALL instruction
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!