6.100L | Fall 2022 | Undergraduate

Introduction to CS and Programming using Python

Lecture 12: List Comprehension, Functions as Objects, Testing, Debugging

Topics: More Functions as Objects, Keyword Arguments, Default Arguments, Debugging: glass box/black box testing, examples

Lecture Notes

Lecture 12: List Comprehension, Functions as Objects, Testing, Debugging

Lecture 12 Code

Readings

Ch 4.4, Ch 8

Finger Exercise Lecture 12

Implement the function that meets the specifications below:

def count_sqrts(nums_list):
    """
    nums_list: a list
    Assumes that nums_list only contains positive numbers and that there are no duplicates.
    Returns how many elements in nums_list are exact squares of elements in the same list, including itself.
    """
    # Your code here

# Examples:    
print(count_sqrts([3,4,2,1,9,25])) # prints 3

6.100L Finger Exercises Lecture 12 Solutions

Problem Set 3

Problem Set 3

Problem Set 3 Code

Recitation 6

Recitations were smaller sections that went over the previous lectures. Files contain recitation notes and worked examples in code.

Recitation 6 Notes and Code

Course Info

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