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
____ is a technique for confirming that q received packet or frame is likely to match what was sent
hammer [34]

Answer:

C. Error checking

Explanation:

I hope this helps

6 0
2 years ago
How would you classify an employee who is punctual, has respect for oneself and others, and takes initiative?
TEA [102]
C. They seem to take care of themselves and others. Can socialize and adapt easily.
6 0
3 years ago
Read 2 more answers
The email_list function receives a dictionary, which contains domain names as keys, and a list of users as values. Fill in the b
zysi [14]

Answer:

Following are the solution to this question:

Please find the attachment of this code.

Explanation:

In this code, an email_list method is declared, that accepts a domains parameter, and in the next step, an empty list and two for loop are defined, in which the first for loop is used for a count parameter value and in the second loop is use the append method to add the given value, and use the return method to print its value, and use the print method to call the "email_list" method.  

3 0
2 years ago
Use the drop-down menus to complete the statements about using column breaks in word 2016
Naily [24]

Answer: Breaks in the word 2016 what do you mean

Explanation:

7 0
2 years ago
Read 2 more answers
The type of software used widely in businesses to complete specific tasks is _____. application software programming language sy
max2010maxim [7]
It is eather pythone or html
8 0
2 years ago
Read 2 more answers
Other questions:
  • The Table Tools tab provides which two additional tabs?
    5·1 answer
  • What is the rarest Supercar/hypercar you have ever seen?
    7·1 answer
  • When a partition is formatted with a file system and assigned a drive letter it is called a volume?
    10·1 answer
  • Which is the last step in conducting a URL search?
    14·2 answers
  • Explain in your own words how remote-access Trojans (RATs) work. How can these be used by attackers? How would a network adminis
    10·1 answer
  • When creating a shape in Word, what are some available options? Check all that apply. adding text to the shape changing the size
    6·1 answer
  • Ask the user to input a number less than 100. Print all the numbers from that number to 100.
    6·2 answers
  • Pro and Cons of Artificial Intelligence in Art <br><br> You must have 3 statements in each
    14·1 answer
  • Explain different users of computer in briefly?​
    14·1 answer
  • Why are salaried employees often excluded from overtime pay
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!