Introduction to python fall 2023

Elective website for the “Introduction to python spring 2023” at KEA, Copenhagen School of Design and Technology.

These pages contains everything you need for this elective. A few resources, like literature with copyright can be found on Fronter, but will be linked to from these pages.

Underneath is a short description of each sessions learning goals.

Session 1 - Introduction to python

This first week of this elective will be used for introducing this elective and making sure that you all have the software needed to follow along.

You will after this session have an: * overview of how this elective is structured, and what you can expeted to learn during this semester. * basic understanding of a python development enviroment, and know how to use it. * Be able to control your computer through its command line. * Be able to work with python strings, conditions and functions.

Session 2 - Data Structures: List & Tuples

Today’s session is centered around working with data structures in Python, specifically Lists and Tuples. By the conclusion of these sessions, participants will be proficient in using Lists and Tuples, reading and writing to files, and utilizing both the “for” and “while” loops.

Session 3 - Modules & List Comprehensions

This session delves into Python modules, teaching participants to create and utilize both built-in and 3rd party modules. It also introduces list comprehensions as a concise method for list generation. Practical exercises involve working with specific modules like Os, Subprocesses, Zipfile, and Requests. The goal is to empower participants to fetch website data, manage files, and integrate external code seamlessly.

Session 4 - Mandatory assignment

Description will come later

Session 5 - Utilities and Modules

This session delves deeper into Python modules, spotlighting the BeautifulSoup module for web scraping. Participants learn to persistently save modules in Docker containers. The curriculum includes hands-on exercises with Docker and web scraping tasks. Collaboration tools and practices, especially using Docker and GitHub, are also emphasized.

Session 6 - Functions & Decorators

Session 6 delves into Python decorators, enhancing existing code functionality. Drawing parallels with the Spring Framework, decorators in Python modularize and maintain code by adding new features. The session introduces the boilerplate syntax of decorators and offers practical examples. Participants engage in exercises like timing code execution, slowing down code, and decorating game characters. The goal is to provide a comprehensive understanding of decorators and their applications.

Session 7 - OOP

Session focuses on the basics of Object-Oriented Programming (OOP) in Python. By the end, participants will understand classes, objects, inheritance, and Pythonic OOP in relation to other languages like Java. Essential materials include the OOP in Python 3 text, a notebook on classes, and examples from teachings. Exercises involve creating classes for a Bank system, evaluating Python skills using ChatGPT, and building a terminal-based “Angry Bird” game using OOP. Participants are encouraged to explore, iterate upon, and improve given exercises for a deeper understanding.

Session 8 - Encapsulation

Session 8 focuses on the concept of encapsulation in Python, emphasizing the Pythonic approach compared to languages like Java. While Python typically promotes public attributes, the session explores the use of properties for data encapsulation, using the built-in decorator function @property. Participants will learn the significance of properties, their advantages over private attributes in Java, and engage in exercises like creating a car object, bank operations, and a color converter. The session aims to provide a deep understanding of encapsulation and its practical applications in Python.

Session 9 - The Python Data Model

Session 9 delves into the Python data model, emphasizing Python’s protocol-oriented approach. Participants learn to implement specific methods in their classes, enabling interaction with Python’s built-in functions and top-level syntax. For instance, implementing the __len__ method allows the use of the len() function on objects. The session covers methods like __eq__, __contains__, and more, ensuring objects behave like standard Python objects. Practical exercises include enhancing a deck of cards example with various methods.

Session 10 - Generators

Session 10 introduces participants to the concept of making classes iterable using Python generators. The session emphasizes creating generator functions and expressions, allowing for more readable code. Participants will understand how functions in Python are objects and how to make their objects callable. Practical examples include creating an iterator class, mimicking the built-in range function, and generating student data. The goal is to equip learners with the skills to create memory and time-efficient code using iterators and generators.

Session 11 - Context Managers

Session 11 introduces participants to Context Managers in Python, tools that manage resources such as file handling. Context Managers ensure efficient resource management, like automatically closing files after use. Participants will create their own context managers and explore built-in ones. The session covers practical applications with JSON, Pickles, CSV files, and SQLite databases. The goal is to equip learners with skills to manage resources effectively and write cleaner, more efficient code.

Session 12 - Mandatory Assignment 2

Information will come later