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
notsponge [240]
2 years ago
8

8.11 LAB: Filter and sort a list

Computers and Technology
1 answer:
Helen [10]2 years ago
6 0

nums = input("Enter your numbers: ")

lst = nums.split()

new_lst = ([])

for i in lst:

   if int(i) >= 0:

       new_lst.append(int(i))

new_lst.sort()

for x in new_lst:

   print(x, end=" ")

The above code is in case the user enters the numbers.

def func(lst):

   lst.sort()

   for i in lst:

       if i >=0:

           print(i, end=" ")

lst = ([10,-7, 4, 39, -6, 12, 2])

func(lst)

The above code is in case you must input the numbers manually via a function.

I hope this helps!

You might be interested in
A data in database can be presented in _____ format​
Serggg [28]

Answer:

Data is stored in tables, where each row is an item in a collection, and each column represents a particular attribute of the items. Well-designed relational databases conventionally follow third normal form (3NF), in which no data is duplicated in the system. ... With a homogenous data set, it is highly space efficient

6 0
2 years ago
This project was used to drive the VR Robot to number 25 on the Number Grid
Ludmilka [50]

Answer:

B Wait until position y in millimeter should be greater than 500 at least im guessing because you didnt add what the map looked like, making my job MUCH harder

Explanation:

3 0
2 years ago
Give three reasons to use a hard drive as mass storage.
Elena-2011 [213]

Answer:

With that in mind, let's take a look at five places where hard drives shine.

Backups and Archives. ...

Media Libraries. ...

Large Capacity Storage. ...

NAS Drives and Security. ...

RAID Arrays. ...

Other Uses.

6 0
2 years ago
Read 2 more answers
Which button is not present in the font group Home tab?<br> -B<br> -U<br> -I<br> -D
Otrada [13]

Answer:

-i

Explanation:

is the answer of that question

3 0
2 years ago
Read 2 more answers
Mergesort uses the divide-and-conquer technique to sort a list.<br><br> True<br><br> False
NARA [144]

Answer:

True: Merge Sort sorts a list using divide-conquer approach.

<u>Merge_Sort(B,p,n)</u>  //p is the starting index of array B and n is the last index.

1. if(p<n)

2.        q ← (p+n)/2    //divides the list into two sub-lists

2.        Merge_Sort(B, p, q) //sorts the left half

3.        Merge_Sort(B, q+1, n) //sorts the right half.

4.        Merge(B, p, q, n)

<u>Merge(B, p, q, n)</u>

1.l ← q-p+1.  //no. of elements in left half

2.m ← n-q  //no. of elements in right half.

3.for x ← 1 to l

4.      Left[x] = B[p+x -1] //The elements of left half are copied to Left array

5.for y ← 1 to m.

6.      Right[y]= B[q+y]  //The elements of right half are copied to right array

7. x ← 1, y ←1

8.for z ← p to n.

9.      if( Left[x] ≤ Right[y] ) // to merge the two lists Left and Right, the    //elements are compared.

10.     {   A[z] ← Left[x]   //smaller one comes to the merged list.

11.          x++. }

12.    else

13.      {   A[z] ← Right[y]

14.          y++ }

Explanation:

The Merge_Sort(A, p, n) algorithm first divides the whole array into two halves. Then again divides the sub-lists into it's halves and so on.

Then using merge algorithm it compares the elements of both halves one by one and keep it in sorted order.

6 0
3 years ago
Other questions:
  • A viral video is one that can infect your computer with malware. <br> a. True <br> b. False
    6·1 answer
  • On the basic of size, in how many groups do we classify the computers? Name them.<br>.​
    5·1 answer
  • What is the rationale behind the development of an operating system in computing?
    15·1 answer
  • zeroIt is a function that takes one argument and returns no value. The function stores the value 0 back into the parameter. x is
    8·1 answer
  • Incident damage ____ is the rapid determination of the scope of the breach of the confidentiality, integrity, and availability o
    6·1 answer
  • In Java; Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or
    10·1 answer
  • Write a java program that would request user name, id number, and state the time the user has reported at work.​
    12·1 answer
  • What are the side effects of overclocking?
    13·1 answer
  • Implemente a função ao lado, que recebe um preço e um booleano indicando se já está com desconto ou não. Se o preço for maior qu
    8·1 answer
  • Define print_shape() to print the below shape. Example output:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!