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
Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
kogti [31]

Explanation:

i hope this will help you

3 0
2 years ago
How to be fluent in computer
Setler79 [48]

Explanation:

1. Seeing people do technological innovations, so you have some motivation and inspiration to be fluent in computer

2. Try experimenting and trying stuff, like trying to learn how to code, how the internet work, etc.

3. work more with computers, for example, make a note with OneNote, making digital art with blender, adobe illustrator etc.

4. Try to learn how to be better at learning computer, like, if you do mistakes in your learning journey, try to avoid it next time

5. good luck ;)

7 0
2 years ago
Read 2 more answers
Guys, what does Product Analysis mean? please say it in a simple way.
ValentinkaMS [17]

Answer:

edp

Explanation:

4 0
2 years ago
The commands on an Edit menu may change as a result of your actions. True or False
cestrela7 [59]
The answer to the question is true
5 0
3 years ago
Read 2 more answers
Which of the following statements is TRUE of business intelligence (BI) systems? Business intelligence systems are primarily use
Scrat [10]

Answer:

D) Business intelligence systems analyze an organization's past performance to make predictions is the correct answer.

Explanation:

  • Business intelligence systems represent systems that help the business in the decision making and strategic making method.
  • BI provides is applications that help in the analysis, collection, and integration of business information.
  • Business intelligence systems help the organization to analyze the business trends and to find the problems that occur in the business that is required to be examined.

5 0
3 years ago
Other questions:
  • Chandra, a student working on a group project, is trying to decide how to have the whole group suggest revisions for an essay. S
    10·1 answer
  • Someone help ASAP! Match the type of information system with its description.
    13·2 answers
  • After reading the article, "The Impact of Technology", answer the following question.
    7·1 answer
  • Applications software is also known as
    14·2 answers
  • What do you need for digital photography? 1. 2. 3.
    13·1 answer
  • Why must you be careful when handling a hard drive?
    10·1 answer
  • Why was it important for the date format to be standardized by the
    7·1 answer
  • Help my sister with social studies plssssss its about presidents!!
    9·2 answers
  • Draw a flow chart to access the marks of three students. calculate the total avarage and display the result​
    11·1 answer
  • Why is my speedtest is very good but chrome is slow
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!