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
Write a Java code statement for each of following:
Naddik [55]

Answer:

double decimal1, decimal2;

int whole;

Explanation:

Required

Declare 2 decimals and 1 int.

The syntax to declare a variable is:

<em>data-type variable-name;</em>

To declare decimal, we simply make use of double or float data types.

So, we have:

double decimal1, decimal2; ----> for the decimal variables

And

int whole; ---- for the whole number

6 0
3 years ago
Two Technicians are discussing ShopKey Pro. Technician
Vlada [557]

Answer:

Technician A is correct

Explanation:

Contact us is the most common term used in online applications such as in websites, mobile/android application to search contact information. People mostly scanning the “contact us” page to find the contact information, if they want to contact the company or organization.

Why technician A is correct.

Technician A is correct because people always try to find the “Contact us” page to find contact information for asking questions, to provide feedback, or any suggestion if they want to provide. It is hard for people to find contact information to provide feedback or give an idea to improve the ShopKey version in “support” heading under the “help” section. Because people are more inclined to search such information in the “Contact us” page rather than exploring the website to find such contact.

Why technical B is not correct

When people want to provide feedback, ask a question or suggest a new idea, they mostly prefer to search for information in the contact us pages. An ordinary user, who has no knowledge of website management or website hierarchy, search contact information in the “Contact us” page rather than searching in support or in the help section.

3 0
3 years ago
A type of authentication that requires the user to provide something that they know, such
bagirrra123 [75]
The answer would be true
5 0
3 years ago
Write a function named ilovepython that prints out I love Python three times. Then, call that function.
Brums [2.3K]

Answer:

The program to this question can be described as follows:

Program:

def ilovepython(): #defining a method

   for i in range(3): #defining a loop that print messasge three times

       print('I love Python')#print messasge

ilovepython() #calling the method

Output:

I love Python

I love Python

I love Python

Explanation:

Description of the python program can be described as follows:

  • In the above Python program, a method "ilovepython" is defined, inside the method a for loop is used, inside the loop print method is used, that print the message "I love Python".
  • In python for loop is used to iterate over series and we can execute a set of statements with the loop, tuple, series, once for each element in the list.
8 0
3 years ago
King(a. has eaten b.ate c.had eaten) when Airah called​
Alenkinab [10]

Answer:

c

Explanation:

king had eaten when Airah called

3 0
3 years ago
Other questions:
  • A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some
    11·1 answer
  • Invention I chose was radio.
    9·1 answer
  • Individuals with desirable traits will be __________ to have young that survive than individuals without these traits. (2 points
    5·2 answers
  • With ____________________, you can insert and remove a device while the computer is running.
    11·1 answer
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    6·1 answer
  • ANSWER ALL QUESTIONS CORRECTLY PLEASE AND YOU WILL GET A BRAINLIEST AND 10+ POINTS!!!! I WOULD REALLY APPRECIATE IT
    14·1 answer
  • Choose one skill needed to become Computer Network Administrator?
    10·2 answers
  • Mention three types of pipeline hazards​
    6·2 answers
  • A local firewall adds protection to a hardware firewall by protecting a device _______. Select all that apply. WILL GIVE BRAINLI
    6·2 answers
  • the set of methods that can be used to acquire, organize, store, manipulate, and transmit information is known as .
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!