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
zubka84 [21]
3 years ago
7

Write a method doubleUp that doubles the size of a list of integers by doubling-up each element in the list. Assume there's enou

gh space in the array to double the size.
Computers and Technology
1 answer:
Savatey [412]3 years ago
6 0

Answer:

The solution in Python is as follows:

class myClass:

    def doubleUp(self,doubleList):

         doubleList[:0] = doubleList[::2] = doubleList[1::2] = doubleList[:]

       

newlist =  []

n = int(input("Number of elements: "))

for i in range(n):

    num = int(input(": "))

    newlist.append(num)

   

list = myClass()

list.doubleUp(newlist)

print(newlist)

Explanation:

Start by creating a class

The solution in Python is as follows:

class myClass:

Then define the method doubleUp

    def doubleUp(self,doubleList):

The duplicates is done here

         doubleList[:0] = doubleList[::2] = doubleList[1::2] = doubleList[:]

The program main begins here

This defines an empty list        

newlist =  []

This prompts user for number of elements

n = int(input("Number of elements: "))

The following iteration get the elements of the list

<em>for i in range(n):</em>

<em>     num = int(input(": "))</em>

<em>     newlist.append(num)</em>

   

This defines the instance of the class

list = myClass()

This calls the method

list.doubleUp(newlist)

Lastly, this prints the duplicate list

print(newlist)

You might be interested in
What can you look for on a website to indicate that the information it presents is reliable?
dybincka [34]

There are several things you can look for on a website to help you figure out if the information is reliable. The first thing you should evaluate is the audience that the website is intended for. Is it intended for academics? School children? The general public?


The next thing you should look at is the author of the website. Is the author identified? Is the author an expert in their field? Can you establish the author's credibility? Is the author affiliated to an academic institution or credible organisation?


Look at the accuracy of the website. Check for spelling errors, proper grammar, and well-written text. Are there any sources cited? Are those sources credible?


You should also check to see when the information was published. Is the information up to date? Are all of the links up to date and functioning?


There is one last thing you can look at, and this is the domain of the website. Domains like .edu and .gov are more credible than .com or .net domains.

5 0
3 years ago
Sites on the surface web are _____.
Westkost [7]
It’s A because surface website’s are available for everybody but the dark web is opposite

3 0
3 years ago
Read 2 more answers
Given the declaration
STALIN [3.7K]

Answer:

False

Explanation:

There's only one component of the array list which is list[0] which has value 50

7 0
3 years ago
What is the output when you run the following program? print(3 + 7) print("2 + 3")
QveST [7]

print(3+7) will output 10, which is an integer.

print("2+3") will output 2+3, which is a string.

6 0
3 years ago
What is voice recognition system ?​
lys-0071 [83]

Answer: Voice or speaker recognition is the ability of a machine or program to receive and interpret dictation or to understand and carry out spoken commands.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Ms. Rogers wants to see the names of all the students who scored below 25 on the test. Which of these custom options will help h
    5·1 answer
  • Uma organização pode ser entendida como uma instituição ou associação com objetivos predefinidos. Qual é um dos primeiros concei
    10·1 answer
  • A.<br> Post-It note<br> b.<br> notebook<br> c.<br> tutor<br> d.<br> spell check
    14·1 answer
  • What is the color difference between the iMac and iMac Pro
    14·2 answers
  • Columns are labeled with letters and Rows are labeled with numbers.
    5·1 answer
  • Write a method printshampoolnstructions0, with int parameter numCycles, and void return type. If numCycles is less than 1, print
    8·1 answer
  • Suppose a family has had a house fire in which
    7·2 answers
  • To exclude members of a group from the basic permissions for a folder, which type of permission would you assign? Deny Allow Mod
    13·1 answer
  • CLS
    12·1 answer
  • How could the following line of code be shortened?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!