# Intro to Python
## Week 2 Thurs
## `def`, `for`, and `turtle`
### [Prof. Lane](#links) #### [dlane@sdccd.edu](mailto:dlane@sdccd.edu)
#### Virtual Office Hours 10AM & 7PM: #### [sdccd-edu.zoom.us/my/dlane](https://sdccd-edu.zoom.us/my/dlane) #### ``[slides.nlpia.org](https://slides.nlpia.org/)`` --- ## Attendance
#### Open Sublime Text In Sublime Text: - Hit `[Ctrl]+[P]` to find your `*buggy*.py` file - Hit `[Ctrl]+[Shift]+[F]`, type a Python keyword, then hit `[Enter]`
When I call your name, raise your hand and... - Name a type or function - Explain what it does
Tell us one thing about your playful python (or `bash`) journey? note: - [officefile:///home/hobs/code/mesa_python/mesa_python/data/private-fall26/runestone_roster_fall26.ods](officefile:///home/hobs/code/mesa_python/mesa_python/data/private-fall26/runestone_roster_fall26.ods) - Find new `str.*` methods? - Understand `print` `input` `type` and `=` better? - Learn anything about where files are on your computer? ## New Skills - ``str.upper``, ``.lower``, ``.split`` - ``def``ining functions - `for` loops - drawing with `turtle.Turtle` - ``str.format`` note: - You'll learn 2 new keywords `def`, `for` - and a new use for `in` --- ## Announcements ### [syllabus](https://sdccd.instructure.com/courses/2505751/assignments/syllabus) - Attendance drops Sunday and Monday - Labor Day on Monday! - Give me feedback! ### Zoom Office Hours Monday 10AM & 7PM ### [sdccd-edu.zoom.us/my/dlane](https://sdccd-edu.zoom.us/my/dlane) note: - good news and bad news - I start dropping absentee students on Sunday - Labor Day on Monday! - I will be at zoom office hours on Monday - Show up at office hours if you have not attended most of our class sessions - Making attendance is not enough, you need to participate for the entire class --- ## Assignments due Sunday - [Runestone.Academy Module 2](https://runestone.academy/assignment/student/chooseAssignment) - [Canvas Module 2](https://sdccd.instructure.com/courses/2505751/modules) note: - next week [GitLab.com/mesa_python/fall26](https://gitlab.com/mesa_python/fall26) --- ## ``def``ine `print_and_return()` ```python def print2(text): return print(text) ``` note: - improve python style - what does `print()` return - what does our version of `print` return - add a docstring --- ## Hints - improve python style - what does `print()` return? - what does our version of `print` return - add a docstring --- ```python def print_and_return(text): print(text) return text ``` --- ## Hints - add a ``__doc__``string (a special ``# comment``) first! - make it useful in a text adventure or conversation - add another argument --- ```python def greet(greeting, name): """ Greet the user by name enthusiastically! >>> greet('Hi', 'bob') 'Hi Bob!' """ text = greeting + ' ' + name + '!' print(text) return text ``` --- ### Links 1. [slides.nlpia.org](https://slides.nlpia.org)