본문으로 이동
주 메뉴
주 메뉴
사이드바로 이동
숨기기
둘러보기
대문
최근 바뀜
임의의 문서로
미디어위키 도움말
특수 문서 목록
lse
검색
검색
보이기
계정 만들기
로그인
개인 도구
계정 만들기
로그인
로그아웃한 편집자를 위한 문서
더 알아보기
기여
토론
Claude
편집하기 (부분)
문서
토론
한국어
읽기
편집
원본 편집
역사 보기
도구
도구
사이드바로 이동
숨기기
동작
읽기
편집
원본 편집
역사 보기
일반
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보
보이기
사이드바로 이동
숨기기
경고:
로그인하지 않았습니다. 편집을 하면 IP 주소가 공개되게 됩니다.
로그인
하거나
계정을 생성하면
편집자가 사용자 이름으로 기록되고, 다른 장점도 있습니다.
스팸 방지 검사입니다. 이것을 입력하지
마세요
!
==Using Code Blocks in AI Instructions== * Enhancing Clarity and Precision in Technical Communication When working with AI on programming tasks or technical instructions, using code blocks is essential for clear and unambiguous communication. Code blocks help separate code from regular text, preserve formatting, and ensure that the AI interprets your instructions correctly. * Benefits of Using Code Blocks # '''Clarity''': Clearly distinguishes code from surrounding text. # '''Preservation of Structure''': Maintains indentation and line breaks crucial for code readability. # '''Syntax Highlighting''': Many platforms provide language-specific highlighting, enhancing readability. # '''Error Prevention''': Reduces the risk of AI misinterpreting code as regular text or vice versa. # '''Ease of Copy-Pasting''': Facilitates easy transfer of code snippets for testing or implementation. * How to Use Code Blocks # '''Markdown Format''': Use triple backticks (“`) to enclose your code. # '''Specify Language''': After the opening backticks, specify the programming language for proper highlighting. # '''Indentation''': Maintain proper indentation within the code block for readability. # '''Complete Snippets''': Provide complete, runnable code snippets when possible. # '''Comments''': Use in-code comments to explain complex parts or provide context. * Best Practices for Using Code Blocks # '''Context''': Provide explanatory text before and/or after code blocks. # '''Conciseness''': Include only relevant code parts to maintain focus. # '''Consistency''': Use consistent styling and naming conventions across code blocks. # '''Error Handling''': Include error handling in your code examples when relevant. # '''Multiple Examples''': Provide multiple code blocks for complex concepts or different scenarios. * Examples of Effective Code Block Usage '''Example 1: Python Function Definition''' <pre> Here’s how you might define a simple function to calculate the factorial of a number: def factorial(n): if n == 0 or n == 1: return 1 else: return n * factorial(n - 1) # Example usage result = factorial(5) print(f"The factorial of 5 is: {result}") </pre> This code block clearly shows the function definition, includes a recursive implementation, and demonstrates how to use the function. '''Example 2: HTML Structure with CSS''' <pre> Here’s an example of how to structure a simple HTML page with embedded CSS: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Simple Page</title> <style> body { font-family: Arial, sans-serif; line-height: 1.6; margin: 0; padding: 20px; } .container { max-width: 800px; margin: 0 auto; } h1 { color: #333; } </style> </head> <body> <div class="container"> <h1>Welcome to My Page</h1> <p>This is a simple HTML page with some basic styling.</p> </div> </body> </html> </pre> This code block demonstrates a complete HTML structure with embedded CSS, showing how different elements work together. '''Example 3: JavaScript API Request''' <pre> Here’s an example of how to make an API request using JavaScript’s fetch function: async function fetchUserData(userId) { try { const response = await fetch(`https://api.example.com/users/${userId}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log('User data:', data); return data; } catch (error) { console.error('There was a problem fetching the user data:', error); } } // Usage fetchUserData(123) .then(userData => { // Do something with the user data }) .catch(error => { // Handle any errors }); </pre> This code block shows how to structure an asynchronous function for API requests, including error handling and usage example. [https://salesforcefromscratch.co.uk/using-code-blocks-in-ai-instructions/ 부분코드 포함 설명]
요약:
lse에서의 모든 기여는 다른 기여자가 편집, 수정, 삭제할 수 있다는 점을 유의해 주세요. 만약 여기에 동의하지 않는다면, 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다(자세한 사항은
Lse:저작권
문서를 보세요).
저작권이 있는 내용을 허가 없이 저장하지 마세요!
취소
편집 도움말
(새 창에서 열림)
검색
검색
Claude
편집하기 (부분)
새 주제