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 process of ensuring that web pages coded with new or advanced techniques still are usable in browsers that do not offer supp
Leya [2.2K]

Answer:

(C) progressive enhancement

Explanation:

Progressive enhancement is a web design technique that first underlines the main functionality web page and then incorporates increasingly enhanced and advanced features and design levels.

This process enables the users to use and access the basic features of the web pages. These users can use any browser to access the main contents of the web page. Progressive Enhancement also offers an advanced version of the website for those with more advanced and sophisticated computer browsers or faster internet connection.

So the user can access basic features of a web sites as well as the complex features. This process first makes sure the basic intended purpose and main contents of the web site is accessible to all users before adding complex features which are supported by different browsers and devices.

Validation is a process which checks that code of the website is as per the world wide web standards and also checks that content of web pages and design of websites is being properly displayed and the site is accessible. So this is not the correct option.

Technique of altering a web site in a way that it can appear higher in the search engine results is called optimization so this is not a correct option.

7 0
3 years ago
Health informatics is an interdisciplinary field which incorporates theory and methodology from fields in computer science. True
noname [10]

Health informatics is an interdisciplinary field which incorporates theory and methodology from fields in computer science is True.

True

<u>Explanation:</u>

To capture patient health information they used interdisciplinary field which is consists patient information and they diseases and cure treatment taken for that patient. All information is store in digital formatted.

The patient information is stored such as health informatics, nurse and doctor treatment, health treatment, medicine details, clinics information.

Health informatics are used to do further analysis on patient health. Doctors are using this information for their further treatment for their patient also.

Information are also can be used as IOT information so that patient information are readily available.

3 0
3 years ago
Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respect
Irina18 [472]

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Name");

       String name = in.next();

       System.out.println("Enter Age");

       int age = in.nextInt();

       System.out.println("The age of "+name +" is "+age);

   }

}

Explanation:

Java programming language is used to write the code.

The scanner class is used to prompt and receive values for name and age which are stored in the appropriate variables.

The key idea here is using string concatenation in the output statement in order to print the desired output

3 0
3 years ago
4. Write a program to calculate square root and<br>cube root of an entered number .​
nataly862011 [7]

Answer:

DECLARE SUB SQUARE (N)

CLS

INPUT “ENTER ANY NUMBER”; N

CALL SQUARE(N)

END

SUB SQUARE (N)

S = N ^ 2

PRINT “SQUARE OF NUMBER “; S

END SUB

3 0
3 years ago
Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The intege
matrenka [14]

A complete program with the method ShowCar:

import java.util.Scanner; // header file

public class ShowChar

{

public static void main(String[] args)

{

String lnOfText;

int i;

Scanner input = new Scanner(System.in);

System.out.print("Enter a line of text:");

lnOfText = input.nextLine();

System.out.print(" Enter your index: ");

i = input.nextInt();

show_Char(lnOfText,i);

}

public static void show_Char(String str_a, int i)

{

System.out.print(str_a.charAt(i));

}

}

In this program, both the inputs ie. a sentence or line of text as well as the index position is obtained. A method is written to find the string at that particular position. Finally the method prints that character at the particular index.

5 0
3 years ago
Other questions:
  • PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
    11·2 answers
  • What is a critique of the feature detector model of object recognition?​?
    8·1 answer
  • A bicycle combination lock has four rings with numbers 0 through 9. Given the actual numbers and the combination to unlock, prin
    13·1 answer
  • Explain what a hypervisor application is and what it is used for. Pick a hypervisor application and list its requirements
    8·1 answer
  • Words that have a special meaning in a programming language are called
    13·1 answer
  • Which process could you use to add a table to a document?
    14·1 answer
  • Please help it would mean to world to me❤️ (WORD)
    13·1 answer
  • Does the security burden fall primarily on the user? On
    10·1 answer
  • Define a function isPrime that consumes an integer argument and returns 1 if it'a prime number; 0 if it's not a prime number.
    9·1 answer
  • 25 points select 3 options!!!!!!!!!!!!!!!!!!!!!!!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!