Git Product home page Git Product logo

pypart11's Introduction

Part 11

Accompanying resources

Exercise 1

Create a program called *shapes.py

Declare a class called Rectangle

Rectangle class must have the following attributes:

  • length
  • width

Rectangle class must also have the following methods:

  • area
  • perimeter

Declare a class called Square

  • This class must inherit from the Rectangle class.
import shapes
rect = shapes.Rectangle(2, 4)
rect.area()
# 8

square = shapes.Square(8)
square.area()
# 64

square.perimeter()
# 32

Exercise 2

Create a program called gradebook.py

Declare a AliveStatus class.

Requirements: This class must inherit from Enum. It must have two possible symbolic names:

  • Deceased - associated with the value 0
  • Alive - associated with the value 1

Declare a Person class.

Person class must have the following attributes:

  • first_name
  • last_name
  • dob (date of birth)
  • alive (of type AliveStatus)

Person class must also have the following methods:

  • update_first_name
  • update_last_name
  • update_dob
  • update_status

Declare an Instructor class.

  • This class must inherit from the Person class.
  • This class must have an additional attribute called instructor_id.
  • The instructor_id attribute must start with the string "Instructor_" followed by a UUID value.

Hint: Use super class calls.

Declare an Student class.

  • This class must inherit from the Person class.
  • This class must have an additional attribute called student_id.
  • The student_id attribute must start with the string "Student_" followed by a UUID value.

Declare a class called ZipCodeStudent.

  • This class must inherit from the Student class.

Declare another type of student (prek, middle-school, college, etc).

  • This class must inherit from the Student class.

Declare a class called Classroom:

Classroom class must have the following attributes:

  • students - a container for students
  • instructors - a container for instructors

Classroom class must also have the following methods:

  • add_instructor
  • remove_instructor
  • add_student
  • remove_student
  • print_instructors
  • print_students

As per usual, be sure to always be practicing TDD.

 python3 -m unittest test_gradebook.py

pypart11's People

Contributors

nikkiwojo avatar xt0fer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.