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
galina1969 [7]
4 years ago
13

Complete the function remove_all(L, x) so that, given a list L and a target value x, it returns a copy of the list that excludes

all occurrences of x but preserves the order of the remaining elements.

Mathematics
1 answer:
tia_tia [17]4 years ago
4 0

Answer:

Code is given below along with explanation and output.

Step-by-step explanation:

we can use the method of list comprehension to achieve the given task.

In a list comprehension, we create a sub-list of elements which satisfy specific conditions. the condition i !=x makes sure that x would be excluded in the modified list.

def remove_all(L, x):

   return [i for i in L if i != x]

L = [1, 2, 3, 4, 5, 6, 4, 3, 2, 4 ]

print('Before =',L)

L = remove_all(L, 4)

print('After =',L)

Output:

Before = [1, 2, 3, 4, 5, 6, 4, 3, 2, 4]

After = [1, 2, 3, 5, 6, 3, 2]

As you can see we have successfully removed the multiple occurrence of x=4 while preserving the order of the list.

You might be interested in
3. In August, Cory begins school shopping for his triplet daughters. One day, he
Ksju [112]

d=37\

<u>Step-by-step explanation:</u>

Here , we have In August, Cory begins school shopping for his triplet daughters. One day, he  bought 10 pairs of socks for $2.50 each and 3 pairs of shoes for d dollars each.  He spent a total of $135.97. We need to find What does d equal . Let's find out:

One day, he  bought 10 pairs of socks for $2.50 each

Following is the equation for this info:

⇒ Money = 10(2.50)

⇒ Money = 25\

3 pairs of shoes for d dollars each

Following is the equation for this info:

⇒ Money = 3(d)

⇒ Money = 3d\

He spent a total of $135.97

Following is the equation for this info:

⇒ Total-Money = 135.97

⇒ 25+3d=135.97

⇒ 3d=135.97-25

⇒ d=37\

Therefore , d=37\ .

3 0
3 years ago
ASAPPPPPPPPPPPPPP HELPPPPPPPPPPPPPP
Liula [17]

Step-by-step explanation:

hey it's very simple

I just solve this

and ur correct answer is 3rd option

6 0
3 years ago
Algebra one bonus questions
slega [8]

Answer:

y=3/5x+3

y=1/2x+11.5

neither

Step-by-step explanation:

7 0
3 years ago
a cylindrical vase has a diameter of 6 inches at the bottom of the vase there are 9 marbles each of diameter 3 inches the vase i
KiRa [710]

Answer:

<h2>The volume of water in the vase is 339.33 in^3</h2>

Step-by-step explanation:

To calculate the volume of water in the vase we need the following parameters

1. the diameter/radius of the vase

2. the height /level of water in the vase

Given data

diameter d= 6 in

radius = d/2= 6/2 = 3 in

height of water h= 12 in

we know that the expression for the volume of a cylinder is given as

volume=  \pi r^2h

Inserting our data we have

volume= 3.142*3^2*12\\\volume= 3.142*9*12\\\volume= 339.33 in^3

3 0
3 years ago
Solve the following for the variable:<br> 5x – 3 = 2
ra1l [238]
I believe it’s 1 / X= 1
3 0
3 years ago
Read 2 more answers
Other questions:
  • 8 tenths and 7 hunderths can be regrouped as what?
    5·1 answer
  • How do you factor a monomial
    7·1 answer
  • What is 2% of 200???
    6·1 answer
  • Graph the line that has a slope of <br> 1/9 and includes the point (0,9).
    13·1 answer
  • 1) Dada a função, em reais, definida por f(x)=3.x-5. calcule :<br><br> a) f(2)= <br> b) f(-1)=
    5·1 answer
  • What is 8+192x5, please help
    15·2 answers
  • The Pike Ferris Wheel in downtown Long Beach is 90 feet tall.
    10·1 answer
  • Is .12 a rational number
    12·2 answers
  • 10 x n = 360 n = _____ <br> (3 x 4) x 5 = k x (5 x 4) k = ____
    13·2 answers
  • Another i need help bad
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!