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
Studentka2010 [4]
4 years ago
10

The function below takes one parameter: a list of numbers (num_list). Complete the function to return a new list containing only

the negative numbers from the original list. For this question, you'll first want to create an empty list. Then, you'll want to visit every element of the original list checking to see if it is negative. For the negative elements, you'll append them to your new list. Finally, return the new list.
Computers and Technology
1 answer:
agasfer [191]4 years ago
6 0

Answer:

Following are the program in the Python Programming language.

#define function

def negative_num(num_list):

 #set list type variable

 nlist=[]

 #set the for loop

 for n in num_list:

   #check negative numbers

   if(n<0):

     #add the value of n in list

     nlist.append(n)

 #return list

 return nlist

#set new list type variable that store list

newl=[-5,8,-6,3,-4,9,-7]

#print and call the function

print(negative_num(newl))

<u>Output</u>:

[-5, -6, -4, -7]

Explanation:

Here, we define the function "negative_num" and pass an argument "num_list" in its parameter and inside the function.

  • Set new list data type variable "nlist".
  • Set the for loop which iterate as the list.
  • Set the if conditional statement to check the value of the list is less than 0 then, add that negative values in the variable "nlist".
  • Then, return the new list.

Finally, we set a variable "newl" which store the list of negative and positive numbers then, we print and call the function.

You might be interested in
For Java, a program is converted from a text file of code into an executable file by the process of ?
Ludmilka [50]
Ever coded in Java before? What's the thing you have to do each time you save the code in order for it to run properly?
6 0
3 years ago
Don wishes to swap the values of the variables x and y in his program. He adds a line of code which sets the value of x to the v
12345 [234]

Answer:

The correct answer is (c): The value of both x and y will be set to the original value of y.

Explanation:

Let suppose, we assign some value to variable x and to variable y i.e.

var x=10

vary y=15

Then Don adds a line of code which set the value of x to value of y i.e.

x=y

here it is mean that value of x become 15.

So after this line the value of x is 15 and y is also 15

Then he also added a line of code which set the value of y to value of x. i.e.

y=x

By adding this line of code, the value of y is 15 because x is equal to 15.

Therefore, the value of both x and y will be set to the original value of y.

Why other option are not correct

a. After swapping the value of both variable it is impossible that both variable retain original value in it.

b. this option is only true if in this first line he set the value of y to value of x and in the second line set the value of x to value of y.

d. When you swap two values, there is need of third variable for swapping, when you will swap the value only between two variable, only one variable value will be retained and intended swapping will not be performed

5 0
3 years ago
The pc card and cardbus devices are being replaced by what technology?
Ronch [10]
They are replaced by ExpressCard

3 0
3 years ago
What is the left area of a slide called in an electronic presentation?
Anna11 [10]

The answer is Overview of slide show. This is the most common and normal view for electronic presentation, this allows the user to have a view over the current slide on the main pane as well as the slide information preceding and succeeding with the current slide on view on the right pane.

4 0
3 years ago
Read 2 more answers
HELPPPPPPPPP lol pls
dedylja [7]

Answer: im not very good at music but the 4th box goes in seconds first one goes first and silent note last box

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Create a server program and a client program. The client program reads a line from a text file, converts everything to upper cas
    15·1 answer
  • Please help.............​
    7·1 answer
  • Allie needs to add a long row of numbers. She should enter a
    13·2 answers
  • ___________is a security strategy that applies multiple layers of defense because there is an assumption that any single protect
    12·1 answer
  • How to be like Elon Musk who achieved more in his 46 years than we will ever achieve in ten lifetimes?
    13·1 answer
  • What is the name of the hardware device that is used to write the data from hard disk to CD​
    13·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    7·2 answers
  • An algorithm to display multiplication table a number up to 12​
    5·1 answer
  • List of bad websites and why
    10·1 answer
  • List three things to be safer online.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!