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
The part of the computer that provides access to the internet is the
mariarad [96]

Answer:

The Answer B Modem

Explanation:

That is the only way that you want connect to the internet no other part can connect.

Unless you use a ethernet.

Please rate and heart.

thank you for posting this question i am glad i could answer it.

Please make this a brianliest answer thank you.

7 0
2 years ago
. When a function template has two parameterized types, one as the return value, and one as an argument, then _____.
mart [117]

When a function template has two parameterized types, one as the return value, and one as an argument, then THE FIRST TIME MUST BE EXPLICITLY CODED.

Explanation:

  • The act of implicit and explicit coding, and implicit and explicit code, is defined by context of execution of additional behavior or type setting/casting. Specifically, implicit or explicit methods are defined by the contexts in which they are meant to be used.
  • The explicit coding discipline favors clear and explicit expression of intent in the code.
  • The uses-cases dictate the structure of the application. What the application does should not be implicitly hidden in an organization that the framework is trying to dictate you. Avoid having folders like /controllers, /views at the highest level of folders organization, in favor of folders containing features and use-cases: /categories, /products, etc.
  • Template parameter represents a type that has not yet been specified, but that can be used in the template function as if it were a regular type.

4 0
3 years ago
A plan to budget time for studying and activities is referred to as
krok68 [10]

Answer:

a study schedule.

Explanation:

A plan to budget time for studying and activities is referred to as a study schedule. A study schedule is mostly designed by a student and it comprises of their learning goals and objectives, as well as allocated time to start and  complete.

The main purpose of a study schedule is to avail students the opportunity to maximize their time and improve their ability to study by themselves through an organized schedule for specific subjects, courses or class.

3 0
2 years ago
If nobody buys a ticket to a movie, do they still show it?
Serga [27]

It would depend on the movie and the theater policy.....

Hope this helps have a good day

3 0
3 years ago
How does a paper prototype minimize constraints when compared to a digital one
aksik [14]

A regular prototype minimizes constraints if compared to a paper one because possible problems in use can be identified easily.

<h3>What is a prototype?</h3>

This refers to the initial model of a product designed to test the features of the model before it is released to the market.

<h3>What are the differences between digital and paper prototypes?</h3>

Online protoypes are often time-saving, however, because some features of the prototype cannot be tested, a regular protoype is much better to identify possible problems in design or use.

Learn more about prototipes in: brainly.com/question/4622383

#SPJ1

6 0
2 years ago
Other questions:
  • You're working at a large industrial plant and notice a tag similar to the one shown in the figure above. Which of the following
    5·1 answer
  • Assume that scotus is a two-dimensional character array that stores the family names (last names ) of the nine justices on the S
    6·1 answer
  • The part of the computer that provides access to the internet is the-?
    15·2 answers
  • You have activated pop-up blockers in your web browser to prevent pop-up windows from continually interrupting your browsing exp
    14·2 answers
  • The Software Engineering Code of Ethics and Professional Practice was developed by Select one: a. Computer Professionals for Soc
    7·1 answer
  • An ____ is a collection of tools, features, and interfaces that enables users to add, update, manage, access, and analyze the co
    10·1 answer
  • Why is the ketboard calledQWERTY
    11·2 answers
  • Suppose you own a travel agency in a large city. You have many corporate clients, but growth has slowed somewhat Some long-term
    15·1 answer
  • Tres areas donde se aplica la ciencia y tecnologia
    15·1 answer
  • A laptop can be kept on palm to work. [true/false) ​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!