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
amm1812
3 years ago
9

How to interchange first half of the array with second half of array in python?

Computers and Technology
1 answer:
damaskus [11]3 years ago
8 0

Answer:

Following are the code to this question:

l= []#defining an empty list

n=int(input("Enter total element you want to insert: "))#defining variable to input total element

for i in range(0,n):# defining loop to input value in list

   insert=int(input())#defining variable insert to input value

   l.append(insert) # adding the elemenents into the list

x=n//2#calculating midpoint  

l1 =l[:x]#using slicing to hold first-half value in l1 list

l2 =l[x:]#using slicing to hold second-half value in l2 list

print("Before interchange: ")#print message

print ("list : ",l)#print input list

l3=l2 + l1#add value in l3

print("After interchange: ")#print message

#print(l3)  #print list l3

print (str(l3)[1:-1])#print list l3

Output:

please find the attachment.

Explanation:

Description of the code:

  • In the above python program, an empty list l is declared, in the next line, variable n is defined, that input the total number of the list elements. In the next line, the for loop is declared, which uses the insert variable input value and used the append method to add value in the list.
  • In the next step, the variable x is declared, which finds the midpoint of the list, and defines the l1 and l2 lists, that use slicing to hold the first and second half values.
  • In the last step, the l3 list is declared, that adds the l1 and l2 lists and use the print method to print its values.

You might be interested in
Explain your understanding of distributed object system.
Paraphin [41]

Answer:

In the distributing computing, distributed object system is the process in which the distributed object are get distributed in different address space. The distributed object system is the enhancement of the client server model.

Distributed object are basically refers to the software module which are designed in such a way, so that they work together in the network.

And it is distributed physically within the network area and the methods is executed on the basis of remote host in the distributed system.  

7 0
3 years ago
Supplemental security software (such as anti-virus [anti-malware]) is: Generally considered essential for all desktops and lapto
k0ka [10]

Answer:

Explanation:

With an anti-virus, we can search, detect, and delete malware like spyware, worms, Trojans, rootkits, pseudoviruses, etc.

An anti-virus can detect virus with several methods like:

  • Digital signature
  • Heuristic detection
  • Behavior detection
  • Sandbox detection

Is necessary for personal laptops and desktops, even in companies hardware.

7 0
3 years ago
Create a bulleted list of four descriptive terms describing possible values a person may have. These may be your own values, or
Minchanka [31]
Create a bulleted list of four descriptive terms describing possible values a person may have.

* always be true to yourself
* honesty is the best policy
* making mistakes leads you to solutions
* it's ok to be wrong
7 0
3 years ago
Casey Griggs is a very capable computer engineer. Recently, he noticed a problem that computer engineers have, and thought of a
diamong [38]

Answer:

serendipitous

Explanation:

this happened by chance in a positive manner.  

8 0
3 years ago
Both Saturn Technologies and Granite Inc. incur a cost of $200 to manufacture a single unit of a cell phone. However, Saturn Tec
Ghella [55]

Answer:

<em> It implies that Saturn Technologies creates more economic value than Granite Inc. does</em>

Explanation:

<em>Economic value is a measure of the benefit provided by a good or service to an economic agent. It is generally measured relative units of currency, and the interpretation is therefore: what is the maximum amount of money a specific actor is willing and able to pay for the good or service?</em>

5 0
3 years ago
Other questions:
  • Who developed one of the first mathematical models of a multilevel security computer system?
    15·1 answer
  • what are Include the data on usage you gather from your interactions with friends or by listening to people on the radio or on T
    7·1 answer
  • What specific record type is found in every zone and contains information that identifies the server primarily responsible for t
    10·1 answer
  • Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
    14·1 answer
  • 4.3 Code Practice: Question 1
    12·2 answers
  • P16 Consider the following network. ISP B provides national backbone service to regional ISP A. ISP C provides national backbone
    7·1 answer
  • De acuerdo con las generaciones de la computación, ¿Creen que estamos en la 5ta generación o aun no? y ¿por qué?
    13·1 answer
  • What does a hanging indent look like?
    7·1 answer
  • Windows 8 uses a(n) ________ account for easy access and storage of online files.
    10·1 answer
  • When conducting memory and recall tests, some people make an effort to normalize memories by not reporting extreme cases. this l
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!