π Python Day 1: Variables, Data Types & I/O β The Foundation of Every AI App
Introduction
Before you build AI agents, LLM pipelines, or automation tools β you write variables.
Every production AI system, at its core, is managing, transforming, and displaying data.
Day 1 is where real engineers are separated from tutorial followers.
π§ What is a Variable?
A variable is a named reference to an object in memory.
model_name = "claude-sonnet-4-20250514"
temperature = 0.7
is_streaming = True
Python is dynamically typed β variables don't have fixed types. The objects they point to do.
π¦ Python's Core Data Types
| Type | Example | AI/ML Use Case |
|---|---|---|
int |
1000 |
max_tokens, batch_size |
float |
0.7 |
temperature, probability |
str |
"prompt" |
user input, API keys |
bool |
True |
flags, conditions |
NoneType |
None |
missing values |
β¨οΈ Input and Output
name = input("Enter name: ").strip() # always strip input
print(f"Hello, {name}!") # always use f-strings
β οΈ
input()always returns a string. Convert explicitly.
age = int(input("Age: ")) # string β int
price = float(input("Price: ")) # string β float
π€ String Operations β Essential for AI Apps
prompt = " Summarize this document "
prompt.strip() # remove whitespace
prompt.upper() # UPPERCASE
prompt.lower() # lowercase
prompt.title() # Title Case
prompt.replace("document", "report")
len(prompt) # character count
β‘ f-Strings β The Modern Standard
user = "Arjun"
tokens = 1000
print(f"User: {user}, Max Tokens: {tokens}")
print(f"Score: {0.9534:.2f}")
β
Clean
β
Readable
β
Industry standard
π€ Real-World AI App Pattern
# Every LLM app starts like this
user_input = input("Ask AI: ").strip().lower()
system_prompt = (
f"You are a helpful assistant. "
f"User asked: {user_input}"
)
temperature = 0.7
max_tokens = 1000
This is the same foundation used in:
- AI chatbots
- Prompt engineering
- LLM wrappers
- AI automation workflows
- Agent systems
β Common Beginner Mistakes
1. Forgetting type conversion
age = input("Age: ")
print(age + 5) # β Error
2. Using = instead of ==
if age = 18: # β
3. Forgetting .strip()
Extra spaces silently break logic.
4. Confusing None, False, and 0
They are not the same thing.
5. Using old %s formatting
Use f-strings instead.
π― Key Takeaways
- Variables are references, not containers
- Python infers types dynamically
-
input()always returns strings - Always convert types explicitly
- f-strings are the modern standard
- Clean
snake_casenaming looks professional
π What's Next?
β‘οΈ Operators & Expressions
β‘οΈ Conditional Logic (if / elif / else)
β‘οΈ Loops β where automation really begins
π‘ Final Thought
Every advanced AI system starts with simple fundamentals.
Master the basics deeply, and the complex stuff becomes easier later.
Top comments (0)