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
Vinvika [58]
3 years ago
10

Given the lists list1 and list2, not necessarily of the same length, create a new list consisting of alternating elements of lis

t1 and list2 (that is, the first element of list1 followed by the first element of list2 , followed by the second element of list1, followed by the second element of list2, and so on. Once the end of either list is reached, the remaining elements of the longer list is added to the end of the new list. For example, if list1 contained [1, 2, 3] and list2 contained [4, 5, 6, 7, 8], then the new list should contain [1, 4, 2, 5, 3, 6, 7, 8]. Associate the new list with the variable list3.
Computers and Technology
1 answer:
tester [92]3 years ago
5 0

Answer:

The following code is written in Python Programming Language.

Program:

list1=[1,2,3]

 # initialized the list type variable

list2=[4,5,6,7,8]

  # initialized the list type variable

list3=[]

   # initialized the empty list type variable

for j in range(max(len(list1), len(list2))):   #set for loop

 if j<len(list1):

  #set if statement

   list3.append(list1[j])

  #value of list1 appends in list3  

 if j<len(list2):

   #set if statement

   list3.append(list2[j])

  #value of list2 append in list3

print(list3)    #print the list of list3

Output:

[1, 4, 2, 5, 3, 6, 7, 8]

Explanation:

Here, we define three list type variables "list1", "list2", "list3" and we assign value in only first two variables "list1" to [1, 2, 3] and "list2" to [4, 5, 6, 7, 8] and third list is empty.

Then, we set the for loop and pass the condition inside it we pass two if conditions, in first one we compare the list1 from variable "j" inside it the value in list1 will append in list3, and in second one we compare "j" with list two and follow the same process.

After all, we print the list of the variable "list3".

You might be interested in
Write a program that produces the following output:CCCCCCCCC CC CC CC CC CCCCCCCCC Note: The letter C in the output must be uppe
Sergeu [11.5K]

Answer:

CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++

Note: The letter C in the output must be uppercase.

#include <iostream>

using namespace std;

int main()

{

  cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";

  cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";

 

  return 0;

}

 

8 0
3 years ago
Write a program that calls a function to change a variable value from miles to kilometers.
Aneli [31]

Answer:

#include <iostream>

using namespace std;

void miles_to_km(float &miles)//function to convert miles to kilo meters.

{

   miles=miles*1.6;

}

int main() {

   float miles;

   cout<<"Enter the miles"<<endl;

   cin>>miles;//taking input of the miles..

  miles_to_km(miles);//calling function that converts miles to km..

   cout<<"The number of km is "<<miles<<endl;//printing the km.

return 0;

}

Output:-

Enter the miles

54

The number of km is 86.4

Explanation:

I have created  a function miles_to_km of type void which has the argument miles passed by reference.In the function the variable miles is converted to kilo meters.Then in the main function the function is called with the value prompted from the user.Then printing the changed value.

7 0
3 years ago
Priscilla is providing the junior analysts in her firm with some real-world illustrations to explain some of the recommendations
sesenic [268]

Options:

a) The client wants to develop internal resources and capabilities

b) The client is looking for the lowest possible costs

c) The client has unique business requirement that must be satisfied by this software application

d) The client has some existing technology in place whose requirements must be met by the new software

Answer:

d) The client has some existing technology in place whose requirements must be met by the new software

Explanation:

For a client to purchase a software, the client has an already existing technology that requires that software for adequate functioning. The analyst will recommend the new software to the client based on the technology he/she previously has and the requirements he wants to meet.

The other options are not impossible, but they are not the primary reason why the software will be purchased, the overall aim for all the company's activities may be to develop internal resources and capabilities or to meet some unique business requirements, but these are secondary. The primary purpose is that the client has a technology that cannot function properly without the recommended software.

4 0
3 years ago
Write a function swaparrayends() that swaps the first and last elements of the function's array parameter. ex: sortarray
Katena32 [7]
Def swapArrayEnds( array ):
    tmp = array[ len( array ) - 1 ]
    array[ len( array ) - 1 ] = array[ 0 ]
    array[ 0 ] = tmp


3 0
3 years ago
On Election Day, TV news network Houston News One is trying to project the 2018 Texas election results. They send pollsters to 4
Leni [432]

Answer:

entrance poll

Explanation:

Based on the information provided within the question it seems that the type of poll that the news network is conducting is an entrance poll. This refers to asking question (poll) to people outside of the voting center before they enter to place their vote as opposed to exit poll which is done after the individual has placed their vote.

8 0
3 years ago
Other questions:
  • Wi-Fi is all around us. Is there any downside to its pervasiveness?
    11·1 answer
  • Where would you look to see how much space is available on your c drive?
    8·1 answer
  • What are the keys in all rows that sit between the touch keys
    11·1 answer
  • Which one of the following statements referring to mobile Internet
    5·2 answers
  • When you use filter by form to restrict records that appear, you create the filter and then click the ____ button to apply the f
    8·1 answer
  • Do you think children should have their own mobile phones? Why or why not?
    10·2 answers
  • Discuss why it is common for XML to be used in interchanging data over the Internet. What are the advantages of using XML in dat
    7·1 answer
  • What are the defenses to protect against these attacks?
    13·1 answer
  • To rename a worksheet, you change the text on the ? HELP ASAP
    5·1 answer
  • a transport layer security (tls) virtual private network (vpn) requires a remote access server listening on port 443 to encrypt
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!