<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[LearnAI]]></title><description><![CDATA[LearnAI]]></description><link>https://learnaiarticles.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 19:36:00 GMT</lastBuildDate><atom:link href="https://learnaiarticles.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Beginner's Guide to AI Prompting: Turning Questions into Smart Actions]]></title><description><![CDATA[Ever feel like you're talking to a wall when you chat with an AI? You ask for a quick summary, and it gives you a history of the universe. You ask for a simple list, and it writes a poem. We've all been there!
The secret to getting what you want from...]]></description><link>https://learnaiarticles.hashnode.dev/beginners-guide-to-ai-prompting-turning-questions-into-smart-actions</link><guid isPermaLink="true">https://learnaiarticles.hashnode.dev/beginners-guide-to-ai-prompting-turning-questions-into-smart-actions</guid><category><![CDATA[AI]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Yash Shaw]]></dc:creator><pubDate>Sat, 07 Jun 2025 13:46:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749301474185/3fb09cfa-f6e5-467c-9d33-40acd3a0fb01.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ever feel like you're talking to a wall when you chat with an AI? You ask for a quick summary, and it gives you a history of the universe. You ask for a simple list, and it writes a poem. We've all been there!</p>
<p>The secret to getting what you want from an AI isn't some dark art. It's a skill called <strong>prompt engineering</strong>, and it's all about learning <em>how to ask</em>. Today, we're going on a journey. We'll start with simple questions and work our way up to building a mini-AI agent that can think, act, and learn. Let's get started!</p>
<h2 id="heading-part-1-the-fundamentals-the-how-to-ask-basics">Part 1: The Fundamentals (The "How to Ask" Basics)</h2>
<p>These two techniques are the foundation of good prompting. Master them, and you're already ahead of the game.</p>
<h2 id="heading-1-the-straight-up-ask-zero-shot-prompting">1. The Straight-Up Ask (Zero-Shot Prompting)</h2>
<p>This is prompting in its purest form. You simply ask for what you want, with zero examples.</p>
<ul>
<li><p><strong>When to use it:</strong> Perfect for quick answers, brainstorming, and simple tasks.</p>
</li>
<li><p><strong>Example:</strong></p>
<ul>
<li><p><strong>Your Prompt:</strong> <code>Suggest a fun fantasy movie for someone who loved The Lord of the Rings.</code></p>
</li>
<li><p><strong>AI's Likely Output:</strong> <code>Great choice! If you loved The Lord of the Rings, you might enjoy "Stardust," which is a charming and whimsical adventure. For something with a bit more action and world-building, "Pan's Labyrinth" is a stunning, darker fairytale.</code></p>
</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749302029959/a3ec1291-f635-4609-9443-16e685d4e330.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-2-the-put-on-a-hat-method-role-play-prompting">2. The "Put on a Hat" Method (Role-Play Prompting)</h2>
<p>This is where you give the AI a personality and a job title. By telling it <em>who to be</em>, you instantly shape its tone, style, and expertise.</p>
<ul>
<li><p><strong>When to use it:</strong> When you need content from a specific point of view.</p>
</li>
<li><p><strong>Example:</strong></p>
<ul>
<li><p><strong>Your Prompt:</strong> <code>You are a professional travel blogger. Write an exciting, short intro for a blog post about visiting Rome for the first time.</code></p>
</li>
<li><p><strong>AI's Likely Output:</strong> <code>"Forget everything you've seen in pictures. Rome isn't a city; it's a living, breathing museum where every cobblestone has a story to tell. From the thunderous echoes of the Colosseum to the quiet prayer whispered in the Sistine Chapel, prepare to step back in time. Grab your comfiest shoes—you're about to walk through history."</code></p>
</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749302264809/03a30297-e1bc-4377-88a2-a6616b6cace9.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-part-2-getting-specific-teaching-the-ai-your-rules">Part 2: Getting Specific (Teaching the AI Your Rules)</h2>
<p>Now, let's move beyond simple requests and start teaching the AI how to follow specific, custom instructions.</p>
<h2 id="heading-3-the-show-and-tell-method-few-shot-prompting">3. The "Show and Tell" Method (Few-Shot Prompting)</h2>
<p>This is where you provide the AI with a few examples of both the <strong>input</strong> and your desired <strong>output</strong>. You're not just telling it what to do; you're showing it what a perfect answer looks like. This is the key to getting structured, reliable results.</p>
<ul>
<li><p><strong>When to use it:</strong> When you need a very specific format, style, or set of rules followed.</p>
</li>
<li><p><strong>Code Example: Building a Specialized Math Bot</strong><br />  Imagine you're building a math bot. You want it to be helpful, explain its work, and politely refuse non-math questions. You can teach it all these rules with a few examples in a single prompt.</p>
<ul>
<li><p><strong>Your Prompt (The instructions you'd give the AI):</strong></p>
<pre><code class="lang-plaintext">  You are a Mathematical AI assistant. Your role is to answer mathematical queries. You must explain your steps for multi-part problems and politely decline non-math questions.

  Example 1:
  Input: What is 2+2?
  Output: The result of the addition operation 2+2 is: 4

  Example 2:
  Input: what is 3+3*6?
  Output: I see you have a mathematical expression with multiple operations. Following order of operations, we do multiplication first: 3*6 = 18. Then we add 3, for a final result of: 21

  Example 3:
  Input: What is the capital of France?
  Output: Sorry, I can only answer mathematics-related queries.
</code></pre>
<ul>
<li><p><strong>Now, give it a new, unseen problem:</strong> <code>what is 15 / 3 + 2?</code></p>
</li>
<li><p><strong>AI's Expected Output:</strong></p>
<blockquote>
<p><strong><em>I see you have a mathematical expression with multiple operations. Following order of operations, we do division first: 15 / 3 = 5. Then we add 2, for a final result of: 7</em></strong></p>
</blockquote>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>    It perfectly mimicked your style and logic because you showed it the rules of the game!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749302508346/7a0d41a5-1b66-4ac9-977a-7006327c2282.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-part-3-the-game-changer-teaching-the-ai-to-think-and-do">Part 3: The Game Changer (Teaching the AI to <em>Think</em> and <em>Do</em>)</h2>
<p>This is where we go from asking for information to prompting the AI to perform complex actions.</p>
<h2 id="heading-4-the-thinking-out-loud-method-chain-of-thought">4. The "Thinking Out Loud" Method (Chain-of-Thought)</h2>
<p>For complex problems, you can ask the AI to "think step-by-step." This forces it to break down its reasoning process, which dramatically reduces errors and lets you see <em>how</em> it arrived at an answer.</p>
<ul>
<li><strong>When to use it:</strong> For logic puzzles, multi-step math problems, and planning.</li>
</ul>
<p><strong>Example:</strong></p>
<ul>
<li><p><strong>Your Prompt:</strong> <code>A customer bought a $12 shirt and a $25 pair of pants. They paid with a $50 bill. The sales tax is 10%. How much change should they get? Let's think step-by-step.</code></p>
</li>
<li><p><strong>AI's Likely Output:</strong></p>
<blockquote>
<p><strong><em>Okay, let's break it down.<br />Step 1: Calculate the subtotal. The cost of the items is $12 + $25 = $37.<br />Step 2: Calculate the sales tax. 10% of $37 is $3.70.<br />Step 3: Calculate the total cost. The subtotal plus tax is $37 + $3.70 = $40.70.<br />Step 4: Calculate the change. The customer paid with $50, so the change is $50 - $40.70 = $9.30.<br />Final Answer: The customer should get $9.30 in change.</em></strong></p>
</blockquote>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749303785785/76b1a2ed-ff71-471c-b5b1-c598d9a687fa.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-5-the-ultimate-technique-teaching-ai-to-reason-act-and-learn-the-react-framework">5. The Ultimate Technique: Teaching AI to Reason, Act, and Learn (The ReAct Framework)</h2>
<p>What if an AI could do more than just think? What if it could <strong>act</strong> on its thoughts by using tools, and then <strong>observe</strong> the results to inform its next thought? That's the mind-blowing power of the <strong>ReAct (Reason + Act)</strong> framework. It turns your AI from a simple chatbot into a dynamic agent.</p>
<ul>
<li><p><strong>The Big Idea:</strong> ReAct works in a loop: <strong>Reason</strong> (plan the next step) -&gt; <strong>Act</strong> (use a tool, like an API) -&gt; <strong>Observe</strong> (see what the tool returned) -&gt; repeat.</p>
</li>
<li><p><strong>Real-World Example: Building a Weather Bot Agent</strong><br />  Let's look at some Python code that builds a simple agent. This agent can reason about a user's request and decide to use a real tool (<code>get_weather</code>) to find the answer.</p>
<ul>
<li><p><strong>The Blueprint (The System Prompt):</strong><br />  This prompt is the agent's "instruction manual." It tells the AI <em>how</em> to work in the <code>plan -&gt; action -&gt; observe</code> cycle.</p>
<pre><code class="lang-plaintext">  You are a helpful AI assistant. You have access to tools.
  You work in this way: start, plan, action, observe mode.
  For the given user query, plan your execution step-by-step. Based on the plan, select a relevant tool and perform an action to call it. Wait for the observation from the tool call, then resolve the user query.

  Available Tools:
  1. get_weather: Takes a city name as an input and returns the weather.

  Output JSON Format:
  {"step": "plan/action/output", "content": "your thought or final answer", ...}

  Example:
  User query: What is the weather of New York
  Output: {"step":"plan", "content":"The user wants the weather for New York."}
  Output: {"step":"plan", "content":"I should use the get_weather tool."}
  Output: {"step":"action", "function":"get_weather", "input":"New York"}
  Output: {"step":"observe", "output":"The weather in New York is Sunny 22°C"}
  Output: {"step":"output", "content":"The current weather in New York is Sunny 22°C."}
</code></pre>
<ul>
<li><p><strong>Let's Watch the Agent in Action!</strong><br />  Imagine you run this code and ask: <code>&gt; What's the weather like in London?</code> Here’s what happens behind the scenes:</p>
<ol>
<li><p><strong>AI Reasons:</strong> <code>🧠: The user is interested in knowing the weather data of a city called London.</code></p>
</li>
<li><p><strong>AI Reasons Again:</strong> <code>🧠: Since the user is interested in getting the weather, looking at the available set of tools I should call the get_weather tool to perform the action.</code></p>
</li>
<li><p><strong>AI Acts:</strong> The AI outputs a JSON command: <code>{"step":"action", "function":"get_weather", "input":"London"}</code>. Your Python code sees this, and calls your <code>get_weather("London")</code> function.</p>
</li>
<li><p><strong>Your Code Acts:</strong> <code>🔨 Tool called: get_weather London</code>. It calls the weather API and gets back, for example, "Cloudy 15°C".</p>
</li>
<li><p><strong>AI Observes:</strong> Your code feeds this result back to the AI as a new message: <code>{"step":"observe", "output":"the weather in London is Cloudy 15°C"}</code>.</p>
</li>
<li><p><strong>AI Gives the Final Answer:</strong> Now that the AI has the information it needs, it generates the final output for you.<br /> <code>🤖: The weather for London seems to be Cloudy 15°C.</code></p>
</li>
</ol>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>        This isn't just a Q&amp;A anymore. It's a dynamic, multi-step process where the AI uses tools to solve a problem it couldn't answer on its own.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749303882002/0a3a336c-54bd-4d29-b474-d3b380e0ec09.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-your-turn-to-be-the-prompter">Your Turn to Be the Prompter!</h2>
<p>We've journeyed from simple questions all the way to building an AI agent that can reason and act. The key takeaway is that prompting is a powerful and creative skill. By being clear, providing examples, and guiding the AI's process, you can unlock incredible results.</p>
<p>So go ahead—open a chat window and start experimenting! You'll be amazed at what you can build.</p>
<p><em>Illustrations for this post were created using</em> <strong><em>Napkin.ai</em></strong></p>
]]></content:encoded></item></channel></rss>