From Basic Text to Board-Ready Reports: The Prompt Engineering Trick That Transforms Gemini AI into a Data Analyst + Video

Listen to this Post

Featured Image

Introduction:

The difference between a generic AI response and a professionally structured analytical report often comes down to a single factor: prompt engineering. While large language models (LLMs) like Google Gemini possess immense computational power, their output quality is directly proportional to the clarity and structure of the instructions they receive. By leveraging advanced techniques such as Chain of Thought (CoT) reasoning and Persona Prompting, developers can guide AI to not only solve complex problems but also present solutions in a format suitable for real-world business environments—complete with structured headings, step-by-step logic, and verification sections.

Learning Objectives:

  • Master the implementation of Chain of Thought (CoT) prompting to enhance AI reasoning and transparency.
  • Apply Persona Prompting to tailor AI output format, tone, and professional structure for specific business use cases.
  • Build a practical Python script using the Google Gemini API to compare plain prompts versus engineered prompts side-by-side.

You Should Know:

1. Setting Up Your Google Gemini API Environment

Before diving into prompt engineering, you need a functional development environment. The Google Gemini API provides a straightforward setup process, particularly for educational and experimental purposes with generous free tier access.

Step-by-step guide explaining what this does and how to use it:

This setup creates an isolated Python environment to prevent dependency conflicts and ensures you have all necessary libraries to interact with the Gemini API.

 1. Clone the repository or create your project directory
git clone https://github.com/yourusername/prompt-engineering-setup.git
cd prompt-engineering-setup

<ol>
<li>Create and activate a Conda environment (recommended)
conda create -1 prompt-eng python=3.11 -y
conda activate prompt-eng</p></li>
<li><p>Install required dependencies
pip install google-generativeai python-dotenv</p></li>
<li><p>Obtain your Gemini API key from Google AI Studio
Visit: https://aistudio.google.com/app/apikey
Click "Create API Key" and copy the key (starts with AIzaSy...)</p></li>
<li><p>Set up the API key as an environment variable (recommended)
export GEMINI_API_KEY="your-api-key-here"

For permanent setup, add to your shell configuration:
echo 'export GEMINI_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrc

For Windows users (using PowerShell):

$env:GEMINI_API_KEY="your-api-key-here"

Security Note: Never commit your API key to version control. Use `.env` files and add them to .gitignore. If you accidentally expose your key, revoke it immediately in Google AI Studio and generate a new one.

2. The Plain Prompt Approach: Baseline Output

A plain or “zero-shot” prompt asks the model to solve a problem without any specific instructions about reasoning process or output format. While modern LLMs can often produce correct answers, the presentation is typically minimal and lacks professional structure.

Step-by-step guide explaining what this does and how to use it:

This script sends a direct prompt to Gemini and displays the raw response. It serves as a baseline for comparison with engineered prompts.

import google.generativeai as genai
import os

Configure the API
genai.configure(api_key=os.environ["GEMINI_API_KEY"])

Initialize the model
model = genai.GenerativeModel('gemini-1.5-pro')

Plain prompt - no structure, no persona, no reasoning instructions
plain_prompt = """
A company produces two products: Product A and Product B.
Product A costs $50 to produce and sells for $120.
Product B costs $80 to produce and sells for $200.
The company has a monthly budget of $10,000 for production.
Marketing requires that at least 40% of total units produced are Product B.
What is the maximum monthly profit?
"""

Generate response
response = model.generate_content(plain_prompt)
print("Plain Prompt Response:")
print(response.text)

What this does: This sends a straightforward business problem to Gemini. The model will likely calculate the correct answer, but the output is typically a plain paragraph or simple list of equations—functional but not presentation-ready.

  1. Chain of Thought (CoT) Prompting: Unlocking Reasoning Transparency

Chain of Thought prompting encourages the model to break down complex problems into intermediate logical steps before arriving at a final answer. This technique not only improves accuracy on multi-step tasks but also provides visibility into the model’s reasoning process—crucial for trust and debugging in enterprise applications.

Step-by-step guide explaining what this does and how to use it:

The `”Think step-by-step”` instruction forces the model to externalize its reasoning, making the solution verifiable and educational.

import google.generativeai as genai
import os

genai.configure(api_key=os.environ["GEMINI_API_KEY"])

Using system instructions to enforce reasoning
model = genai.GenerativeModel(
'gemini-1.5-pro',
system_instruction="You are a mathematical problem solver. Always show your step-by-step reasoning before providing the final answer."
)

cot_prompt = """
A company produces two products: Product A and Product B.
Product A costs $50 to produce and sells for $120.
Product B costs $80 to produce and sells for $200.
The company has a monthly budget of $10,000 for production.
Marketing requires that at least 40% of total units produced are Product B.
What is the maximum monthly profit?

Think step-by-step and show all calculations.
"""

response = model.generate_content(cot_prompt)
print("Chain of Thought Response:")
print(response.text)

What this does: The `system_instruction` parameter sets a persistent context for the model. By adding “Think step-by-step,” the model produces a detailed solution pathway. This is particularly valuable for complex business logic, multi-variable optimization, and any scenario where auditability is required. The Gemini 2.5 and 3 series models have native “thinking” capabilities that further enhance this process.

4. Persona Prompting: Engineering Professional Output Format

Persona prompting assigns a specific role or identity to the AI, influencing both the content and the presentation style of the response. When combined with CoT, it transforms a basic calculation into a professionally formatted analytical report.

Step-by-step guide explaining what this does and how to use it:

This script combines Persona and CoT prompting to generate a structured business report with headings, sub-steps, and a verification section—mimicking the workflow of a real data analyst.

import google.generativeai as genai
import os

genai.configure(api_key=os.environ["GEMINI_API_KEY"])

System instruction establishes the persona and output expectations
system_prompt = """
You are an expert Data Analyst and Mathematician with 10+ years of experience in business optimization.
Your responses must be professional, structured, and suitable for presentation to C-level executives.
Always include:
1. A clear problem statement
2. Step-by-step solution with equation substitution
3. A verification section validating the findings
4. Executive summary with actionable recommendations
"""

model = genai.GenerativeModel(
'gemini-1.5-pro',
system_instruction=system_prompt
)

persona_cot_prompt = """
A company produces two products: Product A and Product B.
Product A costs $50 to produce and sells for $120.
Product B costs $80 to produce and sells for $200.
The company has a monthly budget of $10,000 for production.
Marketing requires that at least 40% of total units produced are Product B.
What is the maximum monthly profit?

Please analyze this as a formal business case and provide a comprehensive report.
"""

response = model.generate_content(persona_cot_prompt)
print("Persona + CoT Response:")
print(response.text)

What this does: The system instruction defines a Data Analyst persona and specifies the required output structure. When combined with the CoT prompt, the model generates a report that includes:
– Problem Statement: Restates the business scenario
– Mathematical Formulation: Defines variables and constraints
– Step-by-Step Solution: Shows equation substitution and calculations
– Verification Section: Validates results against constraints
– Executive Summary: Presents actionable recommendations

This mirrors exactly what Aqeeb Ur Rahman demonstrated in his Neurofive Solutions project—the same mathematical input produced a “basic, dry set of equations” with a plain prompt versus a “highly structured report with clear headings, sub-steps, and a distinct verification section” with Persona + CoT.

5. Advanced Configuration: Fine-Tuning Gemini Parameters

Beyond prompt content, Gemini API offers configuration parameters that control response characteristics. Understanding these parameters is essential for production-grade applications.

Step-by-step guide explaining what this does and how to use it:

import google.generativeai as genai
from google.generativeai import types

genai.configure(api_key=os.environ["GEMINI_API_KEY"])

model = genai.GenerativeModel('gemini-1.5-pro')

Configure generation parameters
generation_config = types.GenerateContentConfig(
temperature=0.3,  Lower = more deterministic, higher = more creative
top_p=0.95,  Nucleus sampling threshold
max_output_tokens=2048,  Maximum length of response
stop_sequences=["END"],  Custom stop sequences
candidate_count=1  Number of response variations
)

response = model.generate_content(
"Analyze the business problem and provide a structured report.",
generation_config=generation_config
)

Parameter Guide:

  • Temperature (0.0–1.0): Controls randomness. Lower values (0.1–0.3) produce more focused, deterministic outputs—ideal for analytical tasks. Higher values (0.7–1.0) increase creativity but reduce reliability.
  • Top_p (0.0–1.0): Nucleus sampling. A value of 0.95 means the model considers tokens comprising 95% of the probability mass.
  • Max Output Tokens: Limits response length. For analytical reports, 2048–4096 tokens are typically sufficient.
  • Stop Sequences: Custom strings that halt generation—useful for structured outputs.

For enabling Gemini’s built-in thinking process (available in Gemini 2.5 and 3 series), set `include_thoughts=True` in the request configuration to access the model’s internal reasoning summaries.

6. System Instructions for Output Guardrails and Safety

System instructions are a powerful tool for establishing persistent guidelines across an entire conversation. They can define personas, enforce output formats, and implement safety guardrails.

Step-by-step guide explaining what this does and how to use it:

import google.generativeai as genai

genai.configure(api_key=os.environ["GEMINI_API_KEY"])

System instruction with persona, format, and safety constraints
system_instruction = """
You are a Senior Financial Analyst at a Fortune 500 company.
Your responses must:
- Be professional and data-driven
- Use Markdown formatting with clear headings and bullet points
- Include confidence intervals for all numerical predictions
- Flag any assumptions made during analysis
- Never provide investment advice—only present data and calculations
- If a query is outside your expertise, clearly state so
"""

model = genai.GenerativeModel(
'gemini-1.5-pro',
system_instruction=system_instruction
)

response = model.generate_content("Analyze the profitability of Product A versus Product B.")
print(response.text)

What this does: The system instruction acts as a persistent “constitution” for the model. It ensures every response maintains the desired professional tone, format, and safety boundaries—critical for deploying AI in regulated industries or customer-facing applications. This approach reduces hallucinations and output variability by constraining the model’s behavior from the outset.

7. Iterative Prompt Refinement: From Good to Great

Prompt engineering is rarely a one-shot process. Professional practitioners treat it as an iterative cycle of testing, analyzing, and refining.

Step-by-step guide explaining what this does and how to use it:

Step 1: Start with a Baseline

Run the plain prompt and document the output quality, accuracy, and format.

Step 2: Add One Technique at a Time

  • First iteration: Add CoT ("Think step-by-step")
  • Second iteration: Add Persona (system instruction)
  • Third iteration: Add output structure requirements

Step 3: Compare and Analyze

Use the following Python function to systematically compare responses:

def compare_prompts(model, problem, prompts):
"""Compare multiple prompt variations side-by-side."""
results = {}
for name, prompt in prompts.items():
response = model.generate_content(prompt)
results[bash] = {
"text": response.text,
"token_count": len(response.text.split()),
"has_headings": "" in response.text or "" in response.text
}
return results

prompts = {
"plain": "A company produces... What is maximum profit?",
"cot": "A company produces... Think step-by-step...",
"persona_cot": "You are a Data Analyst... [full prompt]"
}

comparison = compare_prompts(model, problem, prompts)
for name, data in comparison.items():
print(f"\n=== {name.upper()} ===")
print(f"Tokens: {data['token_count']}")
print(f"Has Headings: {data['has_headings']}")
print(data['text'][:500] + "...")

Step 4: Refine Based on Gaps

  • If output lacks structure: Add explicit formatting instructions
  • If output is too verbose: Add conciseness guidelines
  • If output misses verification: Add a verification requirement
  • If output is inaccurate: Add more context or examples (few-shot learning)

What Undercode Say:

  • Key Takeaway 1: The transformation from “basic text” to “professional analytical report” is not a function of model capability alone—it is a function of prompt engineering sophistication. The same Gemini model that produces dry equations can generate board-ready reports when given proper Persona and CoT instructions.

  • Key Takeaway 2: The `system_instruction` parameter in the Gemini API is underutilized. By establishing a persistent persona and output format requirements at the system level, developers can ensure consistency across all interactions—a critical requirement for enterprise AI deployments.

Analysis: Aqeeb Ur Rahman’s demonstration at Neurofive Solutions highlights a fundamental truth about modern LLMs: they are powerful but passive tools that require precise instructions to unlock their full potential. The side-by-side comparison of plain versus Persona+CoT prompts reveals that the difference is not in computational ability but in presentation and reasoning transparency. For businesses, this means that prompt engineering is not an optional “nice-to-have” but a core competency for extracting value from AI investments. The ability to generate structured, verifiable, and professionally formatted outputs directly impacts decision-making speed and confidence. As Gemini’s native thinking capabilities continue to evolve, the gap between engineered and non-engineered prompts will only widen—making prompt engineering skills increasingly valuable for data scientists, analysts, and AI practitioners.

Prediction:

  • +1 The democratization of prompt engineering techniques—particularly through accessible platforms like Google AI Studio and open-source repositories—will accelerate AI adoption in small and medium enterprises, enabling non-technical domain experts to generate professional-grade analytical reports without coding expertise.

  • +1 As Gemini and competing models integrate deeper reasoning capabilities (e.g., native Chain of Thought), the distinction between “plain” and “engineered” prompts will blur, but the need for Persona-based output structuring will intensify as organizations demand consistent brand voice and formatting across all AI-generated content.

  • -1 The over-reliance on prompt engineering as a “silver bullet” may lead to complacency in model selection and fine-tuning. Organizations that neglect to evaluate model performance on their specific data distributions will face accuracy issues that no amount of prompt engineering can fix.

  • +1 The growing body of publicly available prompt engineering resources—including Google’s 68-page guide, the Gemini Cookbook, and community-driven repositories—will lower the barrier to entry and foster a new generation of “prompt engineers” who bridge the gap between business requirements and AI capabilities.

  • -1 Without proper governance, the ease of generating highly structured, convincing reports could lead to over-reliance on AI-generated analysis without human verification—a risk particularly acute in regulated industries where auditability and accountability are paramount.

▶️ Related Video (72% Match):

https://www.youtube.com/watch?v=0nRQ7qI-9SI

🎯Let’s Practice For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

IT/Security Reporter URL:

Reported By: Aqeeb Ur – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky