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 is the result of the following code?<br><br> x=7//2+10%2**4<br><br> print(x)
spin [16.1K]

Answer:

3

Explanation:

We can split the expression into two sections

First Section:

7 // 2 = 3. Using the floor division we only utilize the integer part.

Second Section:

10 % 2**4 = 0**4 = 0

Bringing back the full version expression we have

3 + 0 = 3

7 0
1 year ago
Write a recursive method in pseudo code that returns the number of 1's in the binary representation of n. use the fact that this
Deffense [45]
Int count(int num)

if   num==0   return  0;
return   (n&1)+count (n/2)


4 0
2 years ago
Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
SpyIntel [72]
<span>Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of rewards for doing well in school. As the result of doing well in studies, a person can hang out with friends, watch their own favorite TV show and can buy a new pair of shoes. Hence all these things are the rewards that are being generated for a good performance in school.</span>
8 0
3 years ago
Read 2 more answers
The machine should not be oiled until the
kicyunya [14]
<span>The machine should not be oiled until the recommended time between oilings is up.</span>
6 0
3 years ago
Which task might be suitable for moving into a separate function so you can re-use it from multiple places in your code?
Fudgin [204]

Answer:

The answer is "All of these could make good functions ".

Explanation:

In the given question some information is missing, that is options which can be described as follows:

a. Ask the user to confirm an input with a yes/no answer

b. Sort some input data into an ordered list

c. All of these could make good functions

d. Calculate a complex mathematical expression

A method is a collection of ordered code and provides a generic code, that is used to execute a single, connected operation.

  • A good function is a function, which takes values from the user and it will sort all the data and store in memory, and whenever we call the function, it will give the values.
  • It is also used to calculate some complex values,
8 0
3 years ago
Other questions:
  • if the president goes for vice president after his 2 term and the present president dies is the old president the president agai
    8·2 answers
  • Discuss the importance of employee security awareness training. What innovative ways should company’s implement security trainin
    14·1 answer
  • Wired network are the most reliable and provide the highest speed?
    7·1 answer
  • In working on the conceptual design of the new database, Ken determines that the "office" field in one of the tables must includ
    8·1 answer
  • URGENT!!! Which file format is used mainly in the Microsoft Windows operating system?
    15·2 answers
  • Using ________ as a promotion method will bring return visitors to your site.
    8·1 answer
  • What keyboard functions lets you delete words
    9·2 answers
  • How does the Problem-solving Process help us to solve everyday Problems?
    13·1 answer
  • A health care provider approaches Accenture to help them increase their efficiency through an advanced data science platform.Wha
    8·1 answer
  • Pleaseeeee helpppppppp​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!