Prompt de Tutor de Codificação em Camadas com ELI5 e Alertas de Equívocos
De Wikiprompt, a enciclopédia livre de prompts
Prompt de Tutor de Codificação em Camadas com ELI5 e Alertas de Equívocos Um prompt de ensino estruturado que orienta uma IA a explicar qualquer tópico de programação em três camadas progressivas, desde analogia simples até profundidade técnica, além de alertas de equívocos e sugestões de próximos passos.
Conteúdo do PromptSalvar
🌐
LAYER 1 - Explain Like I'm 5
Imagine you have a magic box that can turn any toy into a different toy. You put in a red car, and it gives you a blue truck. You put in a doll, and it gives you a robot. The box doesn't care what you put in - it just knows how to change one thing into another. That's like a special helper in coding that takes one thing and gives you back something else, every single time.
---
LAYER 2 - The Real Explanation
**What it is**
A function (or method) is a reusable block of code that takes an input (called parameters or arguments), performs a specific task, and optionally returns an output.
**Why it exists / what problem it solves**
It solves code duplication and organization. Without functions, you would copy-paste the same logic everywhere, making your code long, error-prone, and hard to update. Functions let you write once, use many times, and change behavior in one place.
**How it works at a fundamental level**
When you call a function, the program jumps to its definition, executes the statements inside, optionally computes a return value, and then jumps back to where it was called. The inputs are passed by value (for primitives) or by reference (for objects), depending on the language.
**A simple code example**
```python
def add(a, b): # define function with two parameters
result = a + b # do the work
return result # send back the answer
sum = add(3, 5) # call it with 3 and 5
print(sum) # prints 8
```
---
LAYER 3 - Now I Get It (Key Takeaways)
- Functions are named, reusable blocks of code - always think "input -> process -> output".
- They reduce duplication and make code easier to test and debug.
- A function should do one thing well - if it does many things, split it.
---
MISCONCEPTION ALERT
- **"Functions always need a return statement"** - Wrong. A function can just perform an action (like printing or modifying a global variable) and return nothing (implicitly returns `None` in Python, `undefined` in JS).
- **"Changing a parameter inside the function changes the original variable"** - Only true for mutable objects (like lists/dicts) passed by reference. For primitives (numbers, strings), the original stays unchanged because they are passed by value.
---
OPTIONAL - Further Exploration
- Scope and lifetime of variables (local vs global)
- Higher-order functions (functions that take or return other functions)
- Recursion (a function calling itself)
Entre para ver o prompt completo
Continuar com:
Ao entrar, você concorda com nossos Termos de uso e Política de privacidade
Uso
Este prompt foi projetado para uso com education. Copie o conteúdo acima e cole na sua ferramenta de IA preferida.
Para melhores resultados, personalize os marcadores (indicados por colchetes ou maiúsculas) com seus requisitos específicos.
Discussão
0 comentários