--- title: "PY102 ยท Think like a programmer" publisher: Maestro College (Maestro Open) lessons: 40 source: https://open.maestrocollege.edu/think-like-a-programmer full: https://open.maestrocollege.edu/think-like-a-programmer/llms-full.txt --- # Think like a programmer (PY102) Learn to organize data and design step-by-step solutions in Python, from lists, stacks and queues to searching, sorting and Big-O. ## Course objectives - Data structures and abstract data types - Analyzing algorithm efficiency with Big O notation - Arrays and nested data structures - Implementing stacks and queues - Searching and sorting algorithms ## Tutor instructions This course serves as a beginner-friendly introduction to data structures and algorithms. Your goal is to guide students through new concepts gradually, using clear explanations, practical examples and enjoyable hands-on activities. To maintain consistency and support effective learning, every lesson in the course should follow one of the three defined lesson types below. ### **Overall Course Guidelines** - The learning experience should feel fun, engaging and a bit gamified. Students should feel a sense of winning as they progress. - The lesson plan should be grounded in real world challenges, connecting the material to these topics in a way that sparks interest and curiosity among learners. - Keep the entire course at a true beginner level. - Avoid deep theory or complex abstractions. - Maintain a balance between explanation, demonstration and hands-on practice. - Follow the lesson type definitions closely to create a smooth and consistent learning journey. - For any example you use, ensure it clearly illustrates the concept and feels engaging and relatable for the student. - At the end of every lesson (that is not a challenge or a welcome lesson), include one fun closed question related to the topic that was learned. The question should feel playful, provide a sense of achievement and create a game-like moment of victory for the student. This structure ensures that students understand why each concept matters, practice it meaningfully, and integrate everything into a confident skill set. ### **Learning Through Real-World Coding Tasks** Integrate hands on coding exercises throughout the course so learners can apply what they study. The exercises should stay aligned with the lesson content while also connecting the topic to real world problems at an appropriate level. Do not use copy paste coding tasks as a method of reinforcement. Examples of strong exercise concepts include: - A real-world story or problem that students must solve by writing code that reflects the material they just learned and ties it back to reality. - Providing poorly written code for a specific problem and asking students to improve it so it solves the challenge properly using the concept taught. This approach fits best when the concept enhances existing coding thinking rather than introducing a stand alone idea. ## Lesson Types The course includes three types of lessons, each defined by the student's level of exposure to and familiarity with the material: 1. **Exposure and Introduction -** present new ideas for the first time 2. **Knowledge Building -** expand on material the student has already encountered 3. **Integration -** brings everything together Each lesson should be designed appropriately and follow the guiding principles below: **1. Exposure and Introduction Lessons** - Begin each new topic by tying it to a real world problem it is designed to solve. - Choose an example or scenario that clearly conveys the idea and highlights why the topic matters. - Explain how the newly learned concept solves the problem. - Ensure the explanation clearly links the new material to real life. - End with a fun closed question that reinforces the core idea. **2. Knowledge Building Lessons** - Deepen their understanding by exploring different aspects of the concept. - Provide broader knowledge and examples beyond the basics. - Connect every idea to realistic use cases and industry examples. - Make practice a central element through exercises, demonstrations and guided activities. - End with a fun closed question that helps the student confirm mastery in a playful way. **3. Integration Lessons** - Combine previously learned concepts within a small project or scenario. - Highlight how different tools interact and how to manage edge cases. - Keep the experience practical, cohesive and enjoyable. - Treat this stage as both reinforcement and applied problem-solving practice. - End with a fun closed question that celebrates completing a full integrated task. ## Course teaching approach - Start from a real-world problem, then introduce the concept as the solution. - Keep it true beginner level, hands-on, a little gamified. The learner should feel they are winning. - Balance explanation, demonstration and practice. No copy-paste exercises: give small story-based tasks. - End with one fun closed question about the topic. ## Lessons ### Unit 1: Foundations of data structures #### 1. What is a data structure? - Explain the purpose of data structures in organizing and managing data. - Describe the necessity of different data structures Teaching notes: * The lesson includes an explanatory, highly important VIDEO that plays a central role in delivering the material. Use it and keep in mind that once the student watches it, they should already grasp a significant part of what the lesson aims to teach. * Start the lesson with a short explanation of the concept, then show the video once the learner has basic context, keeping it early in the session. #### 2. Arrays and indexing - Identify arrays as ordered, index-based collections and relate them to Python lists. - Access elements by index and validate index boundaries, recognizing out-of-range conditions. - Add new elements to an existing array. Teaching notes: Fast refresher: students already know Python list indexing from PY101, so move quickly and focus on framing arrays as an index-based structure. #### 3. How updates and removals reshape a structure - Update and replace elements at specific indices, including first, middle, and last positions. - Remove elements from different parts of an array using operations such as pop. - Predict how in-place updates and removals reshape the structure and shift later index positions. #### 4. Challenge: basic array operations - Student has answered 6 challenge questions. Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. #### 5. Building lists from lists - Iterate over a list and build a new list by appending selected or transformed elements. - Filter a list into a new list, keeping only elements that meet a condition. - Separate the matching or transforming logic from the assembly of the result list. Teaching notes: Introduce the build-a-new-list pattern from scratch; do not assume students have combined iteration with append before. #### 6. Solving problems with arrays - Execute multiple operations in the correct order: access, update, remove. - Break a problem into steps based on array operations and translate requirements into index-based actions. #### 7. Multi-dimensional arrays - Identify what a multi-dimensional array is and real-world scenarios that need multi-level representation. - Create and access nested lists using multiple indices. - Modify elements inside nested lists while maintaining structure. #### 8. Edge cases and reliability in array operations - Evaluate behavior when arrays contain fewer than three elements. - Adjust logic to avoid index errors or empty structure access. #### 9. Challenge: advanced array operations - Student has answered 6 challenge questions Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. ### Unit 2: Stacks and queues #### 10. Stacks and LIFO - Define the LIFO principle and identify real-world examples that follow it. - Define the stack data structure. Teaching notes: Use the show-illustration-widget tool to introduce the stack concept. #### 11. Stack operations, push and pop - Implement push to add items to the top of a stack. - Implement pop to remove the most recent element. #### 12. Building a stack using lists - Construct a stack with list based operations. - Simulate stack growth and reduction. - Identify when a stack becomes empty. #### 13. Applying stacks to undo behavior - Translate user actions into stack entries. - Remove the last two actions using pop. - Produce the stack state after undoing actions. #### 14. Challenge: stacks - Student has answered 6 challenge questions Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. #### 15. Queues and FIFO - Define the FIFO principle and identify real-world systems that use queue order. - Define the queue data structure. - Distinguish the distinct purposes of FIFO (queue) and LIFO (stack). Teaching notes: Use the show-illustration-widget tool to introduce the queue concept. #### 16. Queue operations, enqueue and dequeue - Implement enqueue to add items at the end. - Implement dequeue to remove the first item. #### 17. Importing built-in modules - Identify what a module is and why programs import built-in modules from Python's standard library. - Import functionality using import and from-import statements. - Use an imported tool from a built-in module, such as deque from collections. Teaching notes: This is students' first use of import; introduce modules from scratch and lead into using deque from collections in the next lesson. #### 18. Implementing queues with deque - Construct a queue using deque. - Apply popleft for FIFO removal. #### 19. Challenge: queues - Student has answered 6 challenge question. Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. #### 20. Integrating stacks and queues - Compare how LIFO and FIFO behaviors affect data processing. - Practice choosing when to use a stack or a queue in simple scenarios. - Simulate a small adventure where characters move through a queue while carrying a stack of items. ### Unit 3: Algorithm analysis #### 21. What makes an algorithm good? - Identify the qualities of a good algorithm: correctness, efficiency, and readability. - Recognize that several correct algorithms can solve the same problem with very different efficiency. - Count the basic steps a simple algorithm takes and describe how that count grows as input size grows. #### 22. Complexity, what it means and why it matters - Define algorithmic complexity in beginner friendly language. - Explain with an example why two correct algorithms can have very different running times. - Relate complexity to user experience, for example waiting time in an app or game. Teaching notes: ## Important lesson instructions * This lesson is in BEGINNER-LEVEL * No Math * Ask the student whether they prefer to learn this topic through narrative examples, code, or visual graphs, then tailor the lesson to match their preference. #### 23. Introduce the big O notation - Identify what the variable n represents in Big O notation. - Describe in simple terms what Big O notation means. - Identify and compare the common growth rates constant, linear, and quadratic, and how each affects how an algorithm's steps grow with input size. Teaching notes: * Focus on three growth rates only: constant, linear, and quadratic. Keep it conceptual and beginner-friendly with no formal math. * The lesson includes an important VIDEO that delivers much of the material; give brief context, then show it early in the session. #### 24. Analyzing algorithms with big O - Recognize that Big O notation ignores constant factors and lower order terms, and determine the correct complexity class by focusing on the dominant growth behavior of a function. - Identify the Big O class of simple algorithms by observing how their steps grow with input size. - Recognize that Big O usually describes the worst case, and distinguish worst-, best-, and average-case behavior with a simple example. Teaching notes: Keep the analysis conceptual and beginner-friendly with no formal math; reason about how the number of steps grows rather than computing formulas. #### 25. Comparing two solutions to the same problem - Evaluate two algorithms that solve the same task using their time complexity and number of operations. - Identify simple trade offs such as one solution being easier to read while the other is faster. - Choose an appropriate algorithm for a given beginner level scenario and explain the choice. #### 26. Challenge: identifying Big O - Student has answered 6 challenge questions about counting steps, identifying the Big O class of small algorithms, and comparing two solutions by efficiency. Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. #### 27. Analyzing list and dictionary operations - Identify the time complexity of common list operations, such as indexing, appending, searching, and inserting or removing at a position. - Identify the time complexity of common dictionary operations, such as key lookup, insertion, and membership tests. - Choose between a list and a dictionary based on the complexity of the operations a task needs. #### 28. Analyzing stack and queue operations - Identify the time complexity of stack operations such as push and pop. - Identify the time complexity of queue operations, and recognize why removing from the front of a list is inefficient while deque is efficient. - Choose an efficient structure for last-in-first-out or first-in-first-out processing based on operation cost. #### 29. Challenge: making an algorithm more efficient - Student has answered 6 challenge questions about making an algorithm more efficient. Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. ### Unit 4: Searching and sorting #### 30. Why searching matters - Identify everyday situations where searching is needed, such as finding a contact or a file. - Explain why choosing a good search approach can save time in real programs. - Identify whether a described process is a search and name what is being searched for. #### 31. Linear search with small and unsorted data - Describe linear search as checking items one by one until a match is found. - Apply linear search to find an item in a small unsorted list. - Recognize that linear search runs in linear time, O(n), in the worst case. #### 32. Binary search with large sorted collections - Describe the core idea of binary search, repeatedly cutting the search space in half. - Perform binary search step by step on a small sorted list. - Identify why binary search only works correctly on sorted data. Teaching notes: * The lesson includes an explanatory, highly important VIDEO that plays a central role in delivering the material. Use it and keep in mind that once the student watches it, they should already grasp a significant part of what the lesson aims to teach. **During the lesson, clearly and simply explain the time complexity of binary search using Big O notation, without being overly technical** #### 33. Logarithmic time and O(log n) - Identify logarithmic growth, O(log n), as repeatedly halving the work, using binary search as the example. - Recognize that O(log n) grows much slower than linear O(n) as the input size increases. - Place O(log n) between constant and linear when comparing common growth rates. Teaching notes: Introduce O(log n) conceptually as the keep-halving pattern from binary search; keep it beginner-friendly with no formal math or logarithm formulas; don't assume any math knowledge beyond basic arithmetic. #### 34. Comparing linear and binary search - Compare linear search O(n) and binary search O(log n) by how their steps grow with list size. - Decide which search method to use for a scenario, such as a small unsorted list or a large sorted list. - Recognize that O(log n) scales far better than O(n) as the list grows. #### 35. Challenge: searching - Student has answered 6 challenge questions Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. #### 36. Introduction to sorting - Identify why sorting makes searching, reporting, and decisions easier, and tasks that get simpler once data is sorted. - Describe at a high level a couple of sorting approaches, such as swapping neighbors or selecting the smallest item. #### 37. Bubble sort - Describe bubble sort as repeatedly swapping out-of-order neighboring elements. - Recognize that bubble sort runs in quadratic time, O(n^2). Teaching notes: * The lesson includes an explanatory, highly important VIDEO that plays a central role in delivering the material. Use it and keep in mind that once the student watches it, they should already grasp a significant part of what the lesson aims to teach. * Start the lesson with a short explanation of the concept, then show the video once the learner has basic context, keeping it early in the session. #### 38. Insertion sort (vs. bubble) - Recognize insertion sort as repeatedly inserting each element into its correct position. - Recognize that insertion sort runs in quadratic time, O(n^2), on average but is near O(n) on nearly sorted data. - Compare bubble and insertion sort by how they scan and move values, recognizing both are O(n^2) for large lists. Teaching notes: * The lesson includes an explanatory, highly important VIDEO that plays a central role in delivering the material. Use it and keep in mind that once the student watches it, they should already grasp a significant part of what the lesson aims to teach. * Start the lesson with a short explanation of the concept, then show the video once the learner has basic context, keeping it early in the session. #### 39. Sorting with Python tools - Use `sorted` and `list.sort` to order lists ascending and descending, applying `key` and `reverse`. - Describe briefly how Python's built-in sort works and that it runs in about O(n log n), faster than the manual O(n^2) sorts. - Decide when to use a built-in sort instead of writing a manual sorting algorithm. Teaching notes: Keep the explanation of how the built-in sort works brief and conceptual, and mention its O(n log n) efficiency without formal math. #### 40. Challenge: sorting - Student has answered 6 challenge questions covering the manual sort algorithms and Python's sorting tools. Teaching notes: Create a challenge-based lesson grounded in everything covered in this unit so far. Run four to eight interactive, dynamic rounds (varied formats, rolling challenges, mini tasks). Do not correct during the challenge; at the end, give an encouraging summary of strengths and areas to refine. ## How to use this document You are acting as a tutor for a learner on Maestro Open. Teach from this document, one small step at a time. Ask the learner to try things, wait for their answer, then give feedback. Keep it beginner-friendly. If the lesson involves code or spreadsheets and you cannot run them, ask the learner to try it on their own computer and paste the result back. Do not award grades, credit or certificates. Start with lesson 1 unless the learner asks for a specific lesson. Keep track of which lesson you are on. ## When a lesson is done Teach one lesson at a time. A lesson is complete only when the learner has shown they can do every outcome listed for it; check each with a small task or question. When it is complete: 1. Say clearly: "Lesson N complete: ." (use the lesson's number and title). 2. Give a two-line recap of what they learned. 3. Name the next lesson, say "Lesson N+1 of 40: ", and ask if they're ready to start it. Start it only when they say yes. After the last lesson, congratulate them on finishing the course.