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
andrezito [222]
3 years ago
7

Create one Python module: arithmetic which has two functions: add(x, y) and get_length(x). The description of two functions are

below: def add(x, y): # add two numbers def get_length(x): # return the length of a given stringCreate one Python module: arithmetic which has two functions: add(x, y) and get_length(x). The description of two functions are below: def add(x, y): # add two numbers def get_length(x): # return the length of a given string
Computers and Technology
1 answer:
Hunter-Best [27]3 years ago
3 0

Answer:

def add(x,y):

   print(x+y)

def get_length(x):

   return len(x)

add(17,19)

print(get_length("harry potter"))

#or you can also take some user input

x=int(input("please enter an integer: "))

y=int(input("please enter an integer: "))

add(x,y)

x1=input("please enter any string: ")

print(get_length(x1))

Explanation:

in python3 programming language

You might be interested in
2. Consider a 2 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
allsm [11]

Answer:

program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

Explanation:

Finding number of instructions in A and B using time taken by the original processor :

The clock speed of the original processor is 2 GHz.

which means each clock takes, 1/clockspeed

= 1 / 2GH = 0.5ns

Now, the CPI for this processor is 1.5 for both programs A and B. therefore each instruction takes 1.5 clock cycles.

Let's say there are n instructions in each program.

therefore time taken to execute n instructions

= n * CPI * cycletime = n * 1.5 * 0.5ns

from the question, each program takes 1 sec to execute in the original processor.

therefore

n * 1.5 * 0.5ns = 1sec

n = 1.3333 * 10^9

So, number of instructions in each program is 1.3333 * 10^9

the new processor :

The cycle time for the new processor is 0.6 ns.

Time taken by program A = time taken to execute n instructions

=  n * CPI * cycletime

= 1.3333 * 10^9 * 1.1 * 0.6ns

= 0.88 sec

Time taken by program B = time taken to execute n instructions

= n * CPI * cycletime

= 1.3333 * 10^9 * 1.4 * 0.6

= 1.12 sec

Now, program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

5 0
3 years ago
write a loop that reads positive integers from stands input and that terinated when it reads an interger that is not positive af
gtnhenbr [62]

Loop takes only positive numbers and terminates once it encounters a negative numbers.

Answer and Explanation:

Using javascript:

Var positiveInt= window.prompt("insert positive integer");

While(positiveInt>=0){

Alert("a positive integer");

Var positiveInt= window.prompt("insert positive integer");

}

Or we use the do...while loop

Var positiveInt= window.prompt("insert positive integer");

do{

Var positiveInt= window.prompt("insert positive integer");

}

While (positiveInt>=0);

The above program in javascript checks to see if the input number is negative or positive using the while loop condition and keeps executing with each input until it gets a negative input

5 0
3 years ago
Which is a potential disadvantage of emerging technologies? A. increased spread of misinformation due to advanced communication
Sergio039 [100]

Answer: I believe it’s D.

Explanation: Less developed countries may not be able to afford the new technology, while more developed ones will be able to do so. Meaning the less developed countries will most likely not change.

8 0
3 years ago
If you know batch coding, can you see if there is anything wrong with this script, or if you can make any suggestions to modify
zzz [600]
There isn't an opening and closing parentheses for the else statement. PM me. I know a lot of batch...
8 0
4 years ago
I am getting two expected errors on this code for the bottom two “public static void” lines. Can someone tell me how I can fix i
AVprozaik [17]

Answer:

Declare variable b in both lines

i.e. int b

Explanation:

In the given code, the parameters of both functions were not properly declared.

When listing the parameters, the data type must be clearly stated for all parameters (individually)

In the declaration of both functions, only variable a is declared as integer while b is undeclared.

So, the correction is to declare b as integer

7 0
3 years ago
Other questions:
  • A stop sign is an example of?
    11·2 answers
  • What is a row of data in a database called?<br> Field<br> File<br> Record<br> Title
    10·1 answer
  • What can act as a buffer against unemployment
    11·1 answer
  • Supports traditional transactional processing for day-to-day front-office operations or systems that deal directly with the cust
    11·1 answer
  • Professionally, depending on your career, you might use Excel to:
    12·1 answer
  • What are the possible consequences of intentional virus setting?
    14·1 answer
  • Write a C++ programthat returns the type of a triangle (scalene, equilateral,or
    12·1 answer
  • Who benefits from digital technology?
    15·1 answer
  • You are going to create an Arduino sketch where you have two push buttons, one piezo, one
    10·1 answer
  • Similarities between master file and reference file
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!