American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

2 PM – Python Object Oriented Programming – Sebastian

July 29, 2023 @ 2:00 pm - 3:00 pm

Today We Did
  1. Completed School System
  2. Began Library System
  3. Continued to understand the differences between attributes and variables
  4. In case you need anything, feel free to email me at sebastian@ayclogic.com
Homework
  1. Create a new folder on your homework submissions called “Library System”
  2. Homework: Complete the remaining methods we mentioned in class. I want you to try your best to reflect on our previous SchoolSystem to think about what we should put in these new methods. Remember user input, the dictionary attributes, and how we loop through dictionaries.

    class code & instructions we went over:

    from book import Book
    class LibrarySystem:
    def __init__(self):
    self.menu = “””
    Please look at below options
    1. Add book
    2. List all books
    3. Find book by name
    4. Find book by id
    5. List all old books
    Enter your selection. Enter ‘quit’ to exit: “””
    self.title_to_book = {}
    self.id_to_book = {}
    def add_book(self):
    print(“\nADD NEW BOOK”)
    title = input(“What is the title? “)
    author = input(“Who is the author? “)
    publish_year = input(“When was it published? “)
    book_id = input(“Enter book id: “)
    book = Book(title, author, publish_year, book_id)
    self.title_to_book[title] = book
    self.id_to_book[book_id] = book
    “””
    for all methods which print book info; choose whether to print each attribute or make a method inside the book class
    “””
    “””
    list_all_books_using_dictionary
    “””
    def list_all_books_using_dictionary(self):
    print(“\nLIST ALL BOOKS”)
    # loop through each book object using ANY of our dictionaries
    for book in self.title_to_book.values():
    pass
    “””
    list_all_old_books
    only print books whose publish_year is less than 2000
    (when should you turn the publish year to an integer?)
    “””
    “””
    find_book_using_id
    (use id_to_book dictionary attribute)
    “””
    “””
    find_book_using_title
    (use title_to_book dictionary attribute)
    “””
    def application_loop(self):
    while True:
    selection = input(self.menu)
    if selection == “quit”:
    print(“Thank you for using the Libray System.”)
    break
    if selection == “1”:
    self.add_book()
    s = LibrarySystem()
    s.application_loop()

Details

Date:
July 29, 2023
Time:
2:00 pm - 3:00 pm
Event Categories:
,
Verified by MonsterInsights