diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09e42bff..efead2d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,18 +5,37 @@ name: Build Documentation using MkDocs on: push: branches: [master] - paths: - - '**.yml' pull_request: branches: [master] +env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + +permissions: + contents: 'write' + id-token: 'write' + pull-requests: 'write' jobs: build: name: Build and Deploy Documentation runs-on: ubuntu-latest + steps: + - name: Checkout Branch + uses: actions/checkout@v3 + if: github.event_name == 'pull_request' + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + persist-credentials: false + - name: Checkout Master - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + if: github.event_name == 'push' + with: + fetch-depth: 0 + persist-credentials: false - name: Set up Python 3.7 uses: actions/setup-python@v2 @@ -27,7 +46,11 @@ jobs: run: | python -m pip install --upgrade pip pip install mkdocs-material - + + - name: Check + run: | + pwd + ls -la - name: Deploy run: | git pull diff --git a/docs/img/stop-sign.png b/docs/img/stop-sign.png new file mode 100644 index 00000000..504458ea Binary files /dev/null and b/docs/img/stop-sign.png differ diff --git a/docs/index.md b/docs/index.md index 78afbb62..7dd08d13 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,30 +1,30 @@ # CoderDojo Twin Cities Python Resources -This GitHub repository is for sharing teaching resources to teach Python. This includes hints on getting your Python environments setup up and extensive lesson plans for serveral enviornments. +This GitHub repository is for sharing teaching resources to teach Python. This includes hints on getting your Python environments setup up and extensive lesson plans for several environments. -Our mentors have used several different envornments for teaching Python. They each have pros and cons. What our mentors like is getting new students started using a graphical programming environment such as turtle graphics libraries. Here are some of our favorite tools: +Our mentors have used several different environments for teaching Python. They each have pros and cons. What our mentors like is getting new students started using a graphical programming environment such as turtle graphics libraries. Here are some of our favorite tools: - [**Trinket.io**](http://trinket.io) is an easy-to use, kid friendly web-based turtle graphics for beginners. - [**Jupyter Notebooks**](https://jupyter.org/) also have some support for turtle graphics. Jupyter Notebooks can be tricky to setup for the first time, but they are the perfect on-ramp for teaching data literacy. - [**Raspberry Pi**](https://www.raspberrypi.org/documentation/usage/python/) - The Raspberry Pi foundation has selected Python as its primary tool for teaching programming. If you have a Raspberry Pi there are many resources for you. Trinket and Jupyter Notebooks will also run on many Raspberry Pi devices. - **Robots** Our students love robots. Python is also the preferred language in many robotics courses. Today we teach beginning robotics with Scratch and Arduino, but we continue to investigate systems like Raspberry Pi robots that can be programmed with Python. Let us know if you have any low-cost kid friendly ideas. We have tested the JetBot and other robots and we continue to look for solutions. -Now lets briefly go into the pros and cons of these systems. +Now let's briefly go into the pros and cons of these systems. ## Learning Python with Trinket -We use the [trinket.io](http://trinket.io) web site to teach our introduction to python. Trinket has a nice turtle graphics library which is ideal for fast visual feedback. Because it is a free and a pure web web based environment it meets the criteria for our courses. There is no complex setup and each student can continue to do development when they are at home. The downside of Trinket is it has limited functionality, only supports Python 2.X in the free version and you must have an internet connection to use Trinket. If you need Python 3.X web +We use the [trinket.io](http://trinket.io) web site to teach our introduction to python. Trinket has a nice turtle graphics library which is ideal for fast visual feedback. Because it is a free and a pure web-based environment it meets the criteria for our courses. There is no complex setup and each student can continue to do development when they are at home. The downside of Trinket is it has limited functionality, only supports Python 2.X in the free version and you must have an internet connection to use Trinket. If you need Python 3.X web version you can use the free [repl.id](https://repl.it/) web site. ## Learning Python with Jupyter Notebooks -You can also use Jupyter Notebooks to draw turtle graphics. The notebook will open a new window to draw your turtle graphis. Getting Jupyter Notebooks is a bit tricky to setup on many PCs. However, once it is setup it offers tens of thousands of sample programs to learn python coding. Jupyter Notebooks are also the preferred tool by many data science professionals. +You can also use Jupyter Notebooks to draw turtle graphics. The notebook will open a new window to draw your turtle graphics. Getting Jupyter Notebooks is a bit tricky to setup on many PCs. However, once it is setup it offers tens of thousands of sample programs to learn python coding. Jupyter Notebooks are also the preferred tool by many data science professionals. An example of a Jupyter Notebook that uses turtle graphs is [here](jupyter/draw-figure.ipynb) ## Learning Python with Raspberry Pi -If you have a Rasperry Pi there are many great ways to learn Python. One of first things is to try out one of the Python development environments for the Raspberry Pi. +If you have a Raspberry Pi there are many great ways to learn Python. One of first things is to try out one of the Python development environments for the Raspberry Pi. ## Learning Python with Robots -Right now we are continuing to try to find the right combination of easy-of-use and low-cost robots to teach python. If you hear of any good tools, please let us know. +Right now, we are continuing to try to find the right combination of easy-of-use and low-cost robots to teach python. If you hear of any good tools, please let us know. ## Target Audience Learning Python is ideal for students that have good keyboarding skills. If students have difficulty with doing functions like copy and pasting text we suggest they start with a block-programming language like Scratch. @@ -32,7 +32,7 @@ Learning Python is ideal for students that have good keyboarding skills. If stu ## List of Concepts Here are some of the concepts we will be learning in this course. If you are already familiar with these concepts you can skip over some of the labs. -- **importing libraries** We need to tell Pyhton what functions we want to use. We will use the import function to tell Python which functions we need to use in our programs. +- **importing libraries** We need to tell Python what functions we want to use. We will use the import function to tell Python which functions we need to use in our programs. - **drawing** Turtle graphs has a set of drawing functions. We will learn to use these to draw patterns on the screen. - **square walk** - teach your turtle to walk in a square and draw figures. - **variables** Variables make our programs easier to read and easier to understand. @@ -41,7 +41,7 @@ Here are some of the concepts we will be learning in this course. If you are al - **functions** Functions allow us to break large programs into chunks that we can give names and can call over and over. - **function parameters** Functions can also take parameters to change the behavior of a function. - **random numbers** Random number functions allow our programs to have the computer select new random number between a range of numbers. -- **lists** Lists alow us to create collections of names. +- **lists** Lists allow us to create collections of names. - **inputs** Inputs allow us to prompt the user for values. - **recursion** Recursion allows us to have programs call themselves to create repeating patterns. - **modules** Once you have a group of related functions you can put them all together into a module. This makes it easier for others to reuse your programs. diff --git a/docs/strategy/index.md b/docs/strategy/index.md new file mode 100644 index 00000000..19f9a5e3 --- /dev/null +++ b/docs/strategy/index.md @@ -0,0 +1,5 @@ +# Teaching Strategies + +## Order of Concepts + +[Order of Concepts](oder-of-concepts.md) \ No newline at end of file diff --git a/docs/strategy/order-of-concepts.md b/docs/strategy/order-of-concepts.md new file mode 100644 index 00000000..bb443658 --- /dev/null +++ b/docs/strategy/order-of-concepts.md @@ -0,0 +1,123 @@ +# Order of Concepts + +## Intro + +What is the role of visual feedback in teaching beginning Python? + +## No Visual Feedback + + +``` +What are the key concepts in learning Python for a 9th +grade student in the US? List the concepts in the order +they should be taught and add justification for ordering. +``` + +1. Introduction to Programming and Python + +Justification: Begin by explaining what programming is and how it allows us to communicate instructions to a computer. Introducing Python's simplicity and readability sets a positive tone for beginners. +2. Setting Up the Development Environment + +Justification: Before coding, students need to install Python and set up an Integrated Development Environment (IDE) or use an online coding platform. This ensures they're ready to practice coding examples. +3. Basic Syntax and Output with print() + +Justification: Learning how to display information is fundamental. The print() function is simple and provides immediate visual feedback, which is motivating for new learners. +4. Variables and Data Types + +Justification: Variables store information that programs manipulate. Understanding data types like integers, floats, strings, and booleans is essential for handling different kinds of data. +5. Basic Operators and Expressions + +Justification: Operators allow students to perform calculations and manipulate data. This includes arithmetic operators (+, -, *, /) and logical operators (and, or, not). +6. User Input with input() + +Justification: Allowing programs to accept user input makes them interactive. Learning to use the input() function helps students understand how to receive and process external data. +7. Conditional Statements (if, elif, else) + +Justification: Conditionals introduce decision-making in programs. They allow the code to execute different actions based on certain conditions, which is critical for dynamic programming. +8. Loops (for and while Loops) + +Justification: Loops enable code to be executed repeatedly without redundancy. Understanding loops is key for tasks that require iteration, like processing items in a list. +9. Lists and Basic Data Structures + +Justification: Lists store collections of items. Introducing lists teaches students how to handle multiple pieces of data efficiently. +10. Functions and Modular Programming - Justification: Functions promote code reusability and better organization. Learning to write functions helps students break down complex problems into manageable pieces. + +11. Introduction to Modules and Libraries - Justification: Python's strength lies in its extensive libraries. Teaching how to import and use modules like math or random expands the functionality available to students. + +12. Basic File Input/Output - Justification: Reading from and writing to files allows programs to handle data persistence. This is important for applications that need to save or load data. + +13. Error Handling with try and except - Justification: Errors are inevitable in programming. Learning to handle exceptions makes programs more robust and helps students debug their code effectively. + +14. Dictionaries and Sets - Justification: These data structures are useful for storing data in key-value pairs (dictionaries) and for handling unique items (sets). They broaden the ways students can manage data. + +15. Introduction to Object-Oriented Programming (OOP) - Justification: OOP introduces classes and objects, allowing for more complex and scalable code. A basic introduction prepares students for advanced programming concepts. + +16. Developing a Simple Project - Justification: Applying learned concepts in a project reinforces understanding. It provides practical experience and a sense of accomplishment. + +17. Review and Next Steps - Justification: Reviewing consolidates knowledge. Discussing next steps keeps students motivated to continue learning, possibly introducing topics like web development or data science with Python. + +By following this progression, students build a strong foundation in Python programming. Each concept builds upon the previous ones, ensuring a smooth learning curve tailored for 9th-grade students. + + +## With Visual Feedback + +``` +Now assume that all students have access to the +trinket.io website that allows students to learn +using turtle graphics to get fast visual feedback. +Generate a list of the key Python concepts and the +order they should be taught. +``` + +1. Introduction to Programming and Python + +Justification: Start by explaining what programming is and introduce Python as an accessible language for beginners due to its readability and simplicity. +2. Setting Up the Development Environment on Trinket.io + +Justification: Guide students on how to use Trinket.io for writing and running Python code, specifically leveraging its support for turtle graphics to provide immediate visual feedback. +3. Introduction to Turtle Graphics + +Justification: Begin coding with turtle graphics to engage students visually. Drawing simple shapes helps them understand basic programming concepts in an enjoyable way. +4. Basic Syntax and Turtle Commands + +Justification: Teach fundamental Python syntax through turtle commands like forward(), backward(), left(), and right(), which illustrate function calls and parameters. +5. Variables and Data Types + +Justification: Introduce variables to store values that control turtle movements (e.g., distances, angles). Cover basic data types like integers and floats in this context. +6. Loops with Turtle Graphics (for and while Loops) + +Justification: Use loops to create patterns and complex shapes, demonstrating iteration in a visually engaging manner. +7. Functions and Code Reusability + +Justification: Teach how to define functions to encapsulate code for drawing specific shapes or patterns, promoting modular programming and code reuse. +8. Conditional Statements (if, elif, else) + +Justification: Introduce decision-making by changing turtle behavior based on conditions (e.g., drawing different shapes based on user input). +9. User Input with input() + +Justification: Make programs interactive by allowing users to influence turtle drawings, enhancing engagement and understanding of input handling. +10. Lists and Data Collections - Justification: Teach lists by storing sequences of colors, movements, or shapes for the turtle to use, illustrating how to manage collections of data. + +11. Randomness and the random Module - Justification: Use the random module to add unpredictability to turtle drawings, making programs more dynamic and fun. + +12. Advanced Turtle Graphics Techniques - Justification: Explore advanced features like setting pen size, colors, filling shapes, and using loops to create intricate designs. + +13. Error Handling with try and except - Justification: Introduce error handling to make programs more robust, especially when dealing with user input that affects turtle actions. + +14. Introduction to Object-Oriented Programming Concepts - Justification: Provide a basic understanding of objects and classes by explaining that the turtle itself is an object with methods and attributes. + +15. Basic File Input/Output (Optional based on Trinket.io capabilities) - Justification: If supported, teach how to read from and write to files to save or load data that influences turtle drawings. + +16. Developing a Comprehensive Turtle Graphics Project - Justification: Apply all learned concepts in a final project where students create their own complex drawing or simple animation, reinforcing their skills and creativity. + +17. Review and Next Steps - Justification: Summarize the key concepts covered and discuss how these skills can be applied to other areas of Python programming, encouraging continued learning. + +By incorporating turtle graphics early and throughout the curriculum, students benefit from immediate visual feedback that enhances understanding and keeps them engaged. This progression builds foundational Python skills while leveraging the interactive capabilities of Trinket.io, providing a tailored and effective learning experience for 9th-grade students. + + + + + + + +``` \ No newline at end of file diff --git a/docs/trinket/02-simple-square.md b/docs/trinket/02-simple-square.md index 97e63a1a..170e9f4d 100644 --- a/docs/trinket/02-simple-square.md +++ b/docs/trinket/02-simple-square.md @@ -28,11 +28,11 @@ Here is a link to the Trinket web site with this program running: [https://trinket.io/python/564899ffe9](https://trinket.io/python/564899ffe9) You can click on this link and then press the Run button. You should see the python code on the left side and the drawing on the right side of your screen. -## Explaination +## Explanation The first three lines will be the same for all our programs. They import the turtle library into our program, create a new turtle object and then assign the turtle a shape icon. Although almost all the turtle libraries work this way, there are some minor differences you will see in future examples. -## Reorinenting your turtle -Note that at the start, the turtle is facing to the right. After the last instruction, it is also facing to the right. This is a common best practice so that the turtle gets reoriented after some drawing function. If you remove the last right(90) function and run the program again you will see the turtle ends up facing upward. But if you rerun the progam you will still get the same square because the orientation of the turtle is not stored between runs. +## Reorienting your turtle +Note that at the start, the turtle is facing to the right. After the last instruction, it is also facing to the right. This is a common best practice so that the turtle gets reoriented after some drawing function. If you remove the last right(90) function and run the program again you will see the turtle ends up facing upward. But if you rerun the program you will still get the same square because the orientation of the turtle is not stored between runs. ## Experiments Can you change the distance and angle the turtle moves? What happens when you change the numbers for the forward and right functions? Can you go left as well as right? diff --git a/docs/trinket/04-loops.md b/docs/trinket/04-loops.md index bcd3022e..41bd796c 100644 --- a/docs/trinket/04-loops.md +++ b/docs/trinket/04-loops.md @@ -28,5 +28,5 @@ dan.write('done with square') ## Experiments 1. Can you make the turtle draw a larger square? Hint: change the distance to be 80. How big can you make the square before the turtle goes off the screen? 2. Can you make a hexagon? This is a figure with six sides. Hint: the angle will need to be 60 and the range limit will need to be 6. -3. Can you make a hexagon? A Hexagon has eight sides. Hints: Try using an angle of 45. -4. Can you make a stop sign? You will need to use a dan.color('red'). a dan.begomfill() and a dan.endfill(). You can add the text of the word "stop" by using dan.moveto(x,y) and dan.write("STOP",None,None, "30pt bold"). You can also use the dan.hideturtle() so that the outline of the turtle is not displayed at the end. See: https://www.youtube.com/watch?v=HhxYt9Lskrw +3. Can you make an octagon? An Octagon has eight sides. Hints: Try using an angle of 45. +4. Can you make a stop sign? You will need to use a dan.color('red'). a dan.beginfill() and a dan.endfill(). You can add the text of the word "stop" by using dan.moveto(x,y) and dan.write("STOP",None,None, "30pt bold"). You can also use the dan.hideturtle() so that the outline of the turtle is not displayed at the end. See: [Python Stop Sign Tutorial](https://www.youtube.com/watch?v=HhxYt9Lskrw) diff --git a/docs/trinket/04a-stop-sign.md b/docs/trinket/04a-stop-sign.md index ae2f13d8..76511db6 100644 --- a/docs/trinket/04a-stop-sign.md +++ b/docs/trinket/04a-stop-sign.md @@ -1,5 +1,7 @@ # Python Turtle Graphics Stop Sign +![](../img/stop-sign.png) + In this lesson, we will use variables and for loop to draw a stop sign. We will also show how to use the penup, pendown, color, begin_fill, end_fill and write functions. Our write function will also change the font size using the ```font=("Arial", 30, "normal")``` parameter. diff --git a/docs/trinket/05-conditionals.md b/docs/trinket/05-conditionals.md index 0a316525..02c5eff8 100644 --- a/docs/trinket/05-conditionals.md +++ b/docs/trinket/05-conditionals.md @@ -10,7 +10,7 @@ Here is the basic syntax of the Python conditional operator. ```py if (i > 2): # do something if i is greater than 2 - else: +else: # do something else when i is exactly 2 or less than 2 ``` @@ -26,7 +26,7 @@ distance = 100 angle = 90 for i in range(1, 5): - # i modulo 2 is the remainer after we divide by 2 + # i modulo 2 is the remainder after we divide by 2 dan.write(i, font=("arial", 16, "normal")) if i > 2: # true if i greater than 2 dan.color('red') @@ -47,7 +47,7 @@ We would like every other side to change color. To do this we will add an if-th i % 2 ``` -In our previous loop lesson, we created an index that started at 1 and then changed to 2, 3 and finally 4. For 1 and 3, the first and third edges the result of divid by 2 will return 1 which is the same as TRUE. For 2 and 4 (the vertical sides of the square), the expression will evaluate to 0 since the remainder of 2/2 and 4/2 is zero. +In our previous loop lesson, we created an index that started at 1 and then changed to 2, 3 and finally 4. For 1 and 3, the first and third edges the result of divide by 2 will return 1 which is the same as TRUE. For 2 and 4 (the vertical sides of the square), the expression will evaluate to 0 since the remainder of 2/2 and 4/2 is zero. ```py import turtle @@ -69,7 +69,7 @@ for i in range(4): dan.write('done with square') ``` -[Conditinal Sqare](https://trinket.io/library/trinkets/5b18dc55c6) +[Conditional Square](https://trinket.io/library/trinkets/5b18dc55c6) Can you make the turtle use a larger pen size? Try dan.pensize(10) for the red and dan.pensize(3) for the blue. diff --git a/mkdocs.yml b/mkdocs.yml index 2a05bca5..eac9e91f 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,7 +59,9 @@ nav: - Advanced Python: - Stock Ticker Analysis: advanced/stocks.md - MNIST Digit Prediction: advanced/mnist.md - + - Strategy: + - Introduction: strategy/index.md + - Order of Concepts: order-of-cocepts.,d - Contributing: - How to Contribute Examples: contribute.md - Contact: @@ -67,7 +69,7 @@ nav: site_description: 'Resources for teaching Python to CoderDojo Twin Cities students.' site_author: 'Dan McCreary' -repo_name: 'python' +repo_name: 'GitHub Repo' repo_url: 'https://github.com/CoderDojoTC/python' # CoderDojo Standards from here down @@ -91,4 +93,10 @@ markdown_extensions: permalink: true plugins: - search +# Google Analytics Site ID: G-EP38Z3PVD5 +extra: + analytics: + provider: google + # https://analytics.google.com/analytics/web/#/p368752593/reports/intelligenthome + property: G-EP38Z3PVD5 diff --git a/src/draw-for-squares-input-colors.py b/src/draw-for-squares-input-colors.py new file mode 100644 index 00000000..c52d21f0 --- /dev/null +++ b/src/draw-for-squares-input-colors.py @@ -0,0 +1,36 @@ +# J.E. Tannenbaum +# Released: 11/10/2021 - Initial release +# 11/10/2021 - Cleaned up and added comments +# https://trinket.io/python/94326b4743 + +import turtle # Load the library +jet = turtle.Turtle() # Create the turtle object and name it +jet.shape("turtle") # Set the shape + +def drawIt(color, distance, angle): + jet.color(color) + jet.begin_fill() + jet.forward(distance) + jet.right(angle) + jet.forward(distance) + jet.right(angle) + jet.forward(distance) + jet.right(angle) + jet.forward(distance) + jet.end_fill() + +# Set the distance and angle variables +distance = 40 +angle = 90 + +colors = [] +for i in range(4): + color = input("Enter a color:") + colors = colors + [color] + +for color in colors: + drawIt(color, distance, angle) + +# We are done, so hide the turtle +jet.hideturtle() +