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
Write a MIPS assembly language program that
8_murik_8 [283]

Answer:

123456789098765432

Explanation:

asdfghjklokjhgfdsasertyujn nbgfdfvbnjujhgvfcdec vgfredfghjmk

5 0
3 years ago
What's the drawback of using Screened Subnet (DMZ)?
lesantik [10]

It's more expensive, it's more difficult to configure and maintain and it can be more difficult to troubleshoot

4 0
3 years ago
According to Amdahl's Law, what is the speedup gain for an application that is 60% parallel and we run it on a machine with 4 pr
rodikova [14]

With four processing cores, we get a speedup of 1.82 times.

<h3>What is Amdahl's Law?</h3>

Amdahl's law exists as a formula that provides the theoretical speedup in latency of the implementation of a task at a fixed workload that can be expected of a system whose resources exist improved.

Amdahl's law exists that, in a program with parallel processing, a relatively few instructions that hold to be completed in sequence will have a limiting factor on program speedup such that adding more processors may not complete the program run faster.

Amdahl's law stands also known as Amdahl's argument. It is utilized to find the maximum expected progress to an overall system when only part of the system exists improved. It is often utilized in parallel computing to indicate the theoretical maximum speed up utilizing multiple processors.

Hence,  With four processing cores, we get a speedup of 1.82 times.

To learn more about Amdahl's Law refer to:

brainly.com/question/16857455

#SPJ4

6 0
1 year ago
...............................
Gemiola [76]

............................

Mark me brainliest^^

7 0
2 years ago
Read 2 more answers
What are the oop concept of java
mash [69]

Answer: OOP concepts in Java are the main ideas behind Java’s Object Oriented Programming. They are abstraction, encapsulation, inheritance, and polymorphism. Grasping them is key to understanding how Java works. Basically, Java OOP concepts let us create working methods and variables, then re-use all or part of them without compromising security.

HOPE THIS HELPED IS NOT SORRY.

4 0
2 years ago
Read 2 more answers
Other questions:
  • How must you rect to a flashing<br> Yellow traffic light?
    9·1 answer
  • List and explain the error in the code
    14·1 answer
  • Keyboards that are widely used on various smartphones and other small portable devices, and which are designed primarily for com
    15·1 answer
  • In addition to using comments and track changes, you can also use the comparison feature for reviewing documents. In this activi
    11·1 answer
  • Caleb is a big fan of science fiction, so he loves picturing the ________ gland as the captain of his personal starship, pulling
    9·1 answer
  • Given the declarations struct BrandInfo { string company; string model; }; struct DiskType { BrandInfo brand; float capacity; };
    11·1 answer
  • Me inculparon de crear una cuenta en Facebook y colocaron el barrio donde vivo, ¿cómo podría demostrar lo contrario? Ayuda urgen
    6·1 answer
  • Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
    9·2 answers
  • If a program compiles fine, but it produces an incorrect result, then the program suffers from _______________.
    11·1 answer
  • Define management styles
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!