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
777dan777 [17]
3 years ago
5

MyProgramming Lab

Computers and Technology
1 answer:
Akimi4 [234]3 years ago
4 0

Answer:

Explanation:

The following code is written in Python. It creates a method for each one of the questions asked and then tests all three with the same test case which can be seen in the picture attached below.

def alternating_list(lst1, lst2):

   lst3 = []

   for x in range(len(lst1)):

       lst3.append(lst1[x])

       try:

           lst3.append(lst2[x])

       except:

           pass

   if len(lst2) > len(lst1):

       lst3.extend(lst2[len(lst1):])

   return lst3

def reverse_alternating(lst1, lst2):

   lst3 = []

   if len(lst1) == len(lst2):

       for x in range(len(lst1) - 1, -1, -1):

           lst3.append(lst1[x])

           lst3.append(lst2[x])

   return lst3

def alternating_list_no_extra(lst1, lst2):

   lst3 = []

   max = 0

   if len(lst1) > len(lst2):

       max = len(lst2)

   else:

       max = len(lst1)

   for x in range(max):

       lst3.append(lst1[x])

       try:

           lst3.append(lst2[x])

       except:

           pass

   return lst3

You might be interested in
What type of address do computers use to find something on a network?
Leona [35]
An Internet Protocol address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. An IP address serves two main functions host or network interface identification and location addressing which can help you a lot.
6 0
3 years ago
Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number
kolbaska11 [484]

Answer:

C++ program explained below for the problem

Explanation:

// UpComingMarathon.cpp : Defines the entry point for the console application.

//header files

#include "stdafx.h" //optional

#include <iostream>

#include <cstring>

#include <fstream>

#include <iomanip>

using namespace std;

//declare the gobal array of type double

double average[5];

//declare the function prototypes

void getData(ifstream& inf, string n[], double runData[][8], int count);

void calculateAverage(double runData[][8], int count);

void print(string n[], double runData[][8], int count);

int main()

{

   string names[5];

   double runningData[5][8];

   ifstream inputfile("input.txt");

   if(inputfile)

   {

        //call the method getData

        getData(inputfile, names, runningData, 5);

   }

   else

   {

        //error message

        cout<<"Sorry! Unable to open the file."<<endl;

        system("pause");

        return 0;

   }

   //close the file

   inputfile.close();

   //call the method calculateAverage to compute the

   //average miliage of each runner

   calculateAverage(runningData, 5);

   //call display the names and their weekly run rate and their averages

   print(names, runningData, 5);

   system("pause");

   return 0;

}

//definition of method getData that reads the data from the file and

//stores the names into array n and run data into runData array

//simultaneously.

void getData(ifstream& inf, string n[], double runData[][8], int count)

{  

   while(!inf.eof())

   {

        for(int i=0;i<count; i++)

        {

            inf>>n[i];

            for(int j=0;j<7;j++)

            {

                inf>>runData[i][j];

            }

        }

   }

}

//definition of method calculateAverage that comptes the total first

//then stores the value of average into the average array

void calculateAverage(double runData[][8], int count)

{

   double total;

   for(int i=0;i<count;i++)

   {

        total=0;

        for(int j=0;j<7;j++)

        {

            total+=runData[i][j];

        }        

        average[i]=total/7;      

   }

}

//definition of method print that prints the output

//in a tabular format

void print(string n[], double runData[][8], int count)

{

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ');

   cout<<endl;

   cout<<"Name"<<setw(6)<<"";

   for(int i=0;i<7;i++)

        cout<<setw(7)<<"Day "<<(i+1);

   cout<<setw(12)<<"Average"<<endl;

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ')<<endl;

   for(int i=0;i<count;i++)

   {

        cout<<n[i]<<setw(8)<<fixed<<"";

        for(int j=0;j<7; j++)

        {

            cout<<setprecision(2)<<fixed<<runData[i][j]<<setw(3)<<"";

        }

        cout<<setw(8)<<average[i];

        cout<<endl;

   }

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<endl;

}

5 0
3 years ago
Which statement is true of arrays? A) Array elements cannot be reset after the array is declared. B) Only whole numbers can be s
vekshin1

Answer:  Option (D) is correct

Explanation:

Array subscripts are used for refereeing to a individual element in the array.It is created by subscript operator for naming it.It can define the value about location often element. Array subscript can contain whole numbers only.

  • Other options are incorrect because array can be reset,other number along with the whole numbers can get stored in array and it can take high execution time.
  • Thus, the correct option is option(D.)
7 0
4 years ago
The __________ web site and list site seclists.org is home to the leading free network exploration tool, nmap.
maksim [4K]
The nmap.org website

Nmap is an open source utility for security auditing and network discovery. Many network admins also use it for networks inventory and monitoring host or service uptime. It uses raw IP packets in novel ways to determine what hosts are available on the network.


8 0
3 years ago
Read 2 more answers
Fordham3 Hardware is known for its consensus buying center culture. Recognizing this corporate culture, someone attempting to se
balandron [24]

Answer: (c) focus exclusively on the head of the buying center.

Explanation:

As Fordham3 Hardware is known for its consensus buying center culture, so someone attempting to sell to Fordham3 should focus exclusively on the head of the buying center.

8 0
3 years ago
Other questions:
  • Your computer running Windows 7 is doing some very strange things with the operating system. You are fairly certain it is not a
    10·1 answer
  • Patti would like more information about product recalls. Which of the following resources would not be reliable and relevant? ww
    12·2 answers
  • Uploading is the process of transferring existing content stored on a server or other computer or device to your device via a ne
    8·1 answer
  • Select what's true about packet sniffers. Check All That Apply Legitimate sniffers are used for routine examination and problem
    15·1 answer
  • Write a program to check if an input is a valid hashtag (starts with #, contains only letters, numbers, and underscore, no space
    6·1 answer
  • Which of the following is one of the tools in REPL.it that helps prevent syntax errors?
    10·1 answer
  • A new PKI is being built at a company, but the network administrator has concerns about spikes of traffic occurring twice a day
    5·1 answer
  • Q1) What would be the output of the program shown in the figure?
    7·1 answer
  • Lookups comes before Tags in the search-time operation sequence. True or False: Lookups can reference Tags.
    15·1 answer
  • Joe is examining the logs for his web server and discovers that a user sent input to a web application that contained the string
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!