6.100L | Fall 2022 | Undergraduate

Introduction to CS and Programming using Python

Lecture 11: Aliasing, Cloning

Topics: Aliasing and cloning, list comprehensions

Lecture Notes

Lecture 11: Aliasing, Cloning

Lecture 11 Code

Readings

Ch 5.3–5.5

Finger Exercise Lecture 11

Implement the function that meets the specifications below:

def remove_and_sort(Lin, k):
    """ Lin is a list of ints
        k is an int >= 0
    Mutates Lin to remove the first k elements in Lin and 
    then sorts the remaining elements in ascending order.
    If you run out of items to remove, Lin is mutated to an empty list.
    Does not return anything.
    """
    # Your code here  

# Examples:
L = [1,6,3]
k = 1
remove_and_sort(L, k)
print(L)   # prints the list [3, 6]

6.100L Finger Exercises Lecture 11 Solutions

Course Info

Instructor
As Taught In
Fall 2022
Learning Resource Types
Lecture Videos
Lecture Notes
Problem Sets
Programming Assignments with Examples
Readings
Recitation Notes