계층형 코딩 튜터 프롬프트 - ELI5 및 오해 경고 포함
Wikiprompt, 무료 프롬프트 백과사전에서
계층형 코딩 튜터 프롬프트 - ELI5 및 오해 경고 포함 코딩 주제를 세 가지 점진적 계층으로 설명하도록 AI를 안내하는 구조화된 교육 프롬프트 - 단순한 비유에서 기술적 깊이까지, 오해 경고와 다음 단계 제안을 포함합니다.
프롬프트 내용저장
🌐
LAYER 1 - Explain Like I'm 5
Imagine you have a big box of LEGO blocks. You want to build a castle, but you don't want to build it from scratch every time. So, you build a special machine that, when you press a button, takes the blocks and snaps them together into a castle shape. You can press the button again and again, and each time it makes a new castle. That machine is like a "function" - you give it the blocks (input), it does the snapping (process), and out pops a castle (output). You don't need to know how the machine works inside; you just press the button.
---
LAYER 2 - The Real Explanation
**What it is:**
A function is a reusable block of code that performs a specific task. It takes inputs (parameters), processes them, and returns an output (or just performs an action).
**Why it exists / what problem it solves:**
It solves code duplication and organization. Without functions, you'd copy-paste the same logic everywhere, making code long, error-prone, and hard to update. Functions let you write once, use many times, and change the logic 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 uses the passed arguments, and then returns control (and possibly a value) back to where it was called. The function has its own scope - variables inside it are local unless explicitly made global.
**Simple code example (Python):**
```python
def add_numbers(a, b): # 'def' defines the function, a and b are parameters
result = a + b # process the inputs
return result # send the output back
sum = add_numbers(5, 3) # call the function with arguments 5 and 3
print(sum) # prints 8
```
---
LAYER 3 - Now I Get It (Key Takeaways)
- Functions are reusable, named blocks of code that take inputs, do work, and return outputs - they prevent repetition and improve maintainability.
- Parameters are placeholders; arguments are the actual values passed when calling. The function's local variables don't leak outside.
- Always design functions to do one thing well - if it does multiple unrelated tasks, split it.
---
MISCONCEPTION ALERT
1. **"Functions always need a return statement."** - False. Functions can just perform an action (like printing or modifying a global) and return `None` implicitly.
2. **"Changing a parameter inside the function changes the original variable."** - Only true for mutable objects (like lists/dicts) passed by reference. For immutable types (integers, strings), the original stays unchanged - the function works on a copy.
---
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)
전체 프롬프트를 보려면 로그인하세요
Continue with:
By logging in, you agree to our Terms of Use and Privacy Policy
사용법
이 프롬프트는 education와 함께 사용하도록 설계되었습니다. 위의 프롬프트 내용을 복사하여 원하는 AI 도구에 붙여넣으세요.
최상의 결과를 얻으려면 자리 표시자(대괄호 또는 대문자로 표시)를 특정 요구 사항으로 사용자 지정할 수 있습니다.
토론
댓글 0개