/
ict
/
techshare_sites
Обзор
Документация
Войти
/
ict
/
techshare_sites
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
OOP-Python-Teacher-Guide.html
468 строк
18 KB
root
Spinning wheel
19 ноя 2025, 13:13
19 ноя 2025, 13:13
01ebf54
Код
Авторство
О чём код?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>OOP in Python - Teacher Guide</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d); color: #333; line-height: 1.6; padding: 20px; } .container { max-width: 1000px; margin: 0 auto; background: rgba(255, 255, 255, 0.95); border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); padding: 30px; } header { text-align: center; padding: 20px 0; margin-bottom: 30px; border-bottom: 3px solid #1a2a6c; } h1 { color: #1a2a6c; font-size: 2.5rem; margin-bottom: 10px; } .subtitle { font-size: 1.3rem; color: #b21f1f; margin-bottom: 15px; } .controls { display: flex; justify-content: space-between; margin: 20px 0; padding: 15px; background: #f0f0f0; border-radius: 10px; } button { padding: 10px 20px; background: #1a2a6c; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem; transition: all 0.3s ease; } button:hover { background: #b21f1f; transform: scale(1.05); } .section { margin-bottom: 40px; padding: 20px; border-radius: 10px; background: #f9f9f9; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); } .section h2 { color: #1a2a6c; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #fdbb2d; } .section p { margin-bottom: 15px; font-size: 1.1rem; } .tip { background: #e8f4f8; border-left: 4px solid #4ECDC4; padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0; } .key-point { background: #fff8e1; border-left: 4px solid #ff9800; padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0; } .example { background: #e8f5e9; border-left: 4px solid #4caf50; padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0; font-family: monospace; } .navigation { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 20px; border-top: 2px dashed #ccc; } .nav-btn { padding: 12px 25px; font-size: 1.1rem; } footer { text-align: center; margin-top: 30px; padding: 20px; color: #666; font-size: 0.9rem; } @media (max-width: 768px) { .container { padding: 15px; } h1 { font-size: 2rem; } .controls { flex-direction: column; gap: 10px; } } </style> </head> <body> <div class="container"> <header> <h1>Object-Oriented Programming in Python</h1> <div class="subtitle">Teacher's Script & Presentation Guide</div> <p>"Any fool can know. The point is to understand." - Albert Einstein</p> </header> <div class="controls"> <button onclick="zoomIn()">Zoom In</button> <button onclick="zoomOut()">Zoom Out</button> <button onclick="toggleBackground()">Toggle Background</button> <button onclick="increaseFont()">Increase Font</button> <button onclick="decreaseFont()">Decrease Font</button> </div> <div class="section"> <h2>Introduction & Opening (Slide 1-2)</h2> <p><strong>Talking Points:</strong></p> <p>Welcome students to the session on Object-Oriented Programming in Python. Begin by explaining that OOP is a fundamental programming paradigm that helps organize and structure code effectively.</p> <p>Quote Steve Jobs: "Objects are like people. They're living, breathing things that have knowledge inside them about how to do things and have memory inside them so they can remember things."</p> <p>This session will help students understand what OOP is, why it matters, and how to implement it in Python.</p> <div class="tip"> <strong>Teacher Tip:</strong> Start with a real-world analogy - compare OOP to constructing houses using architectural blueprints. </div> </div> <div class="section"> <h2>What is OOP? (Slide 3-4)</h2> <p><strong>Talking Points:</strong></p> <p>Explain the house-building analogy:</p> <ul> <li>Drawing = Class</li> <li>House = Instance/Object</li> <li>House-oriented building = Object-oriented programming</li> </ul> <p>Just as blueprints make house construction efficient, classes make code creation and maintenance efficient.</p> <div class="key-point"> <strong>Key Point:</strong> OOP creates blueprints (classes) for managing and creating data, rather than giving direct instructions. </div> </div> <div class="section"> <h2>The Four Pillars of OOP (Slide 5-6)</h2> <p><strong>Talking Points:</strong></p> <p>Introduce the four main principles of OOP:</p> <ol> <li><strong>Polymorphism:</strong> Ability of an object to take many forms (e.g., different types of roofs/windows)</li> <li><strong>Inheritance:</strong> Child classes acquiring properties from parent classes (e.g., adding a garage to a house)</li> <li><strong>Encapsulation:</strong> Protecting data/methods from outside misuse (e.g., keeping kids out of garage with a key)</li> <li><strong>Abstraction:</strong> Hiding complexity by showing only essential features (e.g., focusing on house appearance, not construction materials)</li> </ol> <div class="tip"> <strong>Teacher Tip:</strong> Use visual examples from the presentation slides to reinforce these concepts. </div> </div> <div class="section"> <h2>OOP Across Programming Languages (Slide 7)</h2> <p><strong>Talking Points:</strong></p> <p>Explain that OOP can be implemented in various programming languages:</p> <ul> <li><strong>Java:</strong> Designed specifically for OOP</li> <li><strong>C:</strong> Procedural approach (step-by-step instructions)</li> <li><strong>Python:</strong> Flexible - supports both OOP and procedural programming</li> </ul> <div class="key-point"> <strong>Key Point:</strong> OOP helps organize complex software projects, making code easier to update and reuse. </div> </div> <div class="section"> <h2>Classes and Objects (Slide 8-9)</h2> <p><strong>Talking Points:</strong></p> <p>Define classes as blueprints and objects as instances of those blueprints.</p> <p>Show the basic class creation without __init__:</p> <div class="example"> class house():<br> pass<br><br> house1 = house()<br> house2 = house()<br><br> house1.address = 1234<br> house1.state = "california"<br> house1.Alarm = False<br> house1.price = 300000<br><br> print(house1.state) # california </div> <p>Ask students: What problems might arise with this approach?</p> <div class="tip"> <strong>Teacher Tip:</strong> Have students think about creating 100 houses with this method - it would be very time-consuming! </div> </div> <div class="section"> <h2>The __init__ Method (Slide 10-11)</h2> <p><strong>Talking Points:</strong></p> <p>Introduce __init__ as Python's constructor method that initializes object attributes.</p> <p>Show improved class creation with __init__:</p> <div class="example"> class house():<br> def __init__(self, address, state, Alarm, price):<br> self.address = address<br> self.state = state<br> self.Alarm = Alarm<br> self.price = price<br><br> house1 = house(1234, "california", False, 300000)<br> house2 = house(5678, "texas", True, 100000)<br><br> print(house1.state) # california<br> print(house2.price) # 100000 </div> <div class="key-point"> <strong>Key Point:</strong> The __init__ method automates object creation, making it faster and more efficient. </div> </div> <div class="section"> <h2>Understanding 'self' (Slide 12-13)</h2> <p><strong>Talking Points:</strong></p> <p>Explain that 'self' refers to the specific instance of the class being worked with.</p> <p>Clarify that:</p> <div class="example"> self.address = address </div> <p>is equivalent to:</p> <div class="example"> house1.address = 1234 </div> <p>Show how 'self' enables creating attributes based on other attributes:</p> <div class="example"> class house():<br> def __init__(self, address, street, state):<br> self.address = address<br> self.street = street<br> self.state = state<br><br> self.completeAddress = str(address) + " " + state </div> <div class="tip"> <strong>Teacher Tip:</strong> Emphasize that 'self' is a convention - you could use any name, but 'self' is universally recognized. </div> </div> <div class="section"> <h2>Instance vs Class Variables (Slide 14-15)</h2> <p><strong>Talking Points:</strong></p> <p>Distinguish between instance variables (unique to each object) and class variables (shared by all instances).</p> <ul> <li><strong>Instance variables:</strong> address, state, alarm, price (different for each house)</li> <li><strong>Class variables:</strong> company name, standard features like carpet (same for all houses)</li> </ul> <div class="example"> class house():<br> company_name = "Awesome building company" # Class variable<br><br> def __init__(self, address, state, Alarm, price):<br> self.address = address # Instance variables<br> self.state = state<br> self.Alarm = Alarm<br> self.price = price </div> </div> <div class="section"> <h2>Methods in OOP (Slide 16-17)</h2> <p><strong>Talking Points:</strong></p> <p>Explain that methods are functions defined inside a class that operate on the class's instances.</p> <p>Present the inflation example - houses increasing in value due to inflation:</p> <div class="example"> class house():<br> company_name = "Awesome building company"<br> inflation_coefficient = 1.08<br><br> def __init__(self, address, state, Alarm, price):<br> self.address = address<br> self.state = state<br> self.Alarm = Alarm<br> self.price = price<br><br> def correctPriceMethod(self): # Instance method<br> self.price = self.price * self.inflation_coefficient </div> <div class="key-point"> <strong>Key Point:</strong> A method is a function associated with a class, while a standalone function is not. </div> </div> <div class="section"> <h2>Three Ways to Update Prices (Slide 18-20)</h2> <p><strong>Talking Points:</strong></p> <p>Demonstrate three different approaches to handle the inflation scenario:</p> <p><strong>1. Instance Method:</strong></p> <div class="example"> apartment1 = house(1234, "california", False, 300000)<br> apartment1.correctPriceMethod() # Updates price to 324000 </div> <p><strong>2. Class Method:</strong></p> <div class="example"> apartment2 = house(1234, "california", False, 300000)<br> house.correctPriceMethod(apartment2) # Same result as above </div> <p><strong>3. Standalone Function:</strong></p> <div class="example"> def correctPriceFunction(apartment):<br> return apartment * 1.08<br><br> apartment3Price = 300000<br> apartment3Price = correctPriceFunction(apartment3Price) </div> <div class="tip"> <strong>Teacher Tip:</strong> Highlight that methods tie functionality to specific classes, while functions are more general-purpose. </div> </div> <div class="section"> <h2>Conclusion & Next Steps (Slide 21)</h2> <p><strong>Talking Points:</strong></p> <p>Summarize what students have learned:</p> <ul> <li>What classes are and how to create them</li> <li>The purpose of the 'self' keyword</li> <li>Difference between instance and class variables</li> <li>How methods differ from functions</li> <li>OOP best practices</li> </ul> <p>Suggest next steps for continued learning:</p> <ul> <li>freeCodeCamp's YouTube course on OOP</li> <li>Practice implementing the four pillars: Polymorphism, Encapsulation, Inheritance, Abstraction</li> <li>Work on OOP projects in Python and other languages</li> <li>Explore software design patterns (advanced)</li> </ul> </div> <div class="navigation"> <button class="nav-btn" onclick="prevSection()">Previous Section</button> <button class="nav-btn" onclick="nextSection()">Next Section</button> </div> <footer> <p>Teacher's Guide for Object-Oriented Programming in Python Presentation</p> <p>Use this guide while presenting the slides to ensure smooth delivery and complete coverage of topics</p> </footer> </div> <script> let fontSize = 1; let bgIndex = 0; const backgrounds = [ 'linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d)', '#333', '#1a2a6c', '#b21f1f' ]; function zoomIn() { document.querySelector('.container').style.transform = 'scale(1.05)'; } function zoomOut() { document.querySelector('.container').style.transform = 'scale(1)'; } function toggleBackground() { bgIndex = (bgIndex + 1) % backgrounds.length; document.body.style.background = backgrounds[bgIndex]; } function increaseFont() { fontSize += 0.1; document.body.style.fontSize = fontSize + 'rem'; } function decreaseFont() { if (fontSize > 0.7) { fontSize -= 0.1; document.body.style.fontSize = fontSize + 'rem'; } } function nextSection() { alert("Move to next presentation slide"); } function prevSection() { alert("Move to previous presentation slide"); } </script> </body> </html>