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
In the sentence below, identify the proofreader's marks used.<br><br>Check my answer please :)
Ulleksa [173]
The answer is (A) Close up or Close space


Basically, the best way to learn proofreading marks is to constantly use them and to try and memorize them. In the example above, the marks are categorized as those for inserting, deleting and changing text. In this case the marks represent delete character and close up. The numbers after correction would be (333-1122)
3 0
3 years ago
What are the 3 parts of a browser window? What componets are in each?
Helga [31]
Here are the universal symbols: the minus symbol is minimize, the square(s) are for windowed mode, and the X symbol is for closing the browser. Branliest answer here.
7 0
4 years ago
python Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that ho
Blizzard [7]

Answer:

see explaination

Explanation:

class Taxicab():

def __init__(self, x, y):

self.x_coordinate = x

self.y_coordinate = y

self.odometer = 0

def get_x_coord(self):

return self.x_coordinate

def get_y_coord(self):

return self.y_coordinate

def get_odometer(self):

return self.odometer

def move_x(self, distance):

self.x_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

print(cab.odometer) # will print 8 3+4+1 = 8

5 0
4 years ago
Problem (Commands): Let c be a copy flag and let a computer system have the set of rights {read, write, execute, append, list, m
dlinn [17]

Answer:

Aee explaination

Explanation:

1.

command copy_all_rights(p,q,s)

if read in a[p,s]

then

enter read into a[q,s];

if write in a[p,s]

then

enter write into a[q,s];

if execute in a[p,s]

then

enter execute into a[q,s];

if append in a[p,s]

then

enter append into a[q,s];

if list in a[p,s]

then

enter list into a[q,s];

if modify in a[p,s]

then

enter modify into a[q,s];

if own in a[p,s]

then

enter own into a[q,s];

end

2.

command copy_all_rights(p,q,s)

if own in a[p,s] and copy in a[p,s]

then

enter own into a[q,s];

if modify in a[p,s] and copy in a[p,s]

then

enter modify into a[q,s];

if list in a[p,s] and copy in a[p,s]

then

enter list into a[q,s];

if append in a[p,s] and copy in a[p,s]

then

enter append into a[q,s];

if execute in a[p,s] and copy in a[p,s]

then

enter execute into a[q,s];

if write in a[p,s] and copy in a[p,s]

then

enter write into a[q,s];

if read in a[p,s] and copy in a[p,s]

then

enter read into a[q,s];

delete copy in a[q,s];

end

3.

"q" would be the effect of copying the copy flag along with the right, because q would have copy right to transfter to another, which may not be intended.

3 0
4 years ago
The non-conditional boolean logical and operator is written as ____.
bixtya [17]
False because whhy would it be true. words of logic

3 0
3 years ago
Other questions:
  • Select the correct text in the passage.
    5·1 answer
  • • The length of time between water level measurements/ control adjustments is DT. • If the water level drops to the bottom of th
    13·1 answer
  • Can you shoot video on the Olympus E-410?
    12·2 answers
  • What is the largest positive number one can represent in an eight-bit 2’s complement code? Write your result in binary and decim
    7·1 answer
  • Why was the cooper black font made?
    5·1 answer
  • (1) The Format Painter ___.
    5·1 answer
  • Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
    12·2 answers
  • Explain the role and importance of ict in daily life ?​
    7·1 answer
  • (50 POINTS)
    12·1 answer
  • What is edge computing?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!