6.100L | Fall 2022 | Undergraduate

Introduction to CS and Programming using Python

Lecture 17: Python Classes

Topics: Object Oriented Programming: data abstraction, class def, class instances, methods

Lecture Notes

Lecture 17: Python Classes

Lecture 17 Code

Readings

Ch 10.1

Finger Exercise Lecture 17

Write the class according to the specifications below:

class Circle():
    def __init__(self, radius):
        """ Initializes self with radius """
        # your code here

    def get_radius(self):
        """ Returns the radius of self """
        # your code here

    def set_radius(self, radius):
        """ radius is a number
        Changes the radius of self to radius """
        # your code here

    def get_area(self):
        """ Returns the area of self using pi = 3.14 """
        # your code here

    def equal(self, c):
        """ c is a Circle object
        Returns True if self and c have the same radius value """
        # your code here

    def bigger(self, c):
        """ c is a Circle object
        Returns self or c, the Circle object with the bigger radius """
        # your code here

6.100L Finger Exercises Lecture 17 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