DEV Community

Cover image for Python Day 1: Variables, Data Types & Input/Output for AI Engineers
Tejas Shinkar
Tejas Shinkar

Posted on • Edited on

Python Day 1: Variables, Data Types & Input/Output for AI Engineers

šŸš€ 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

āš ļø input() always returns a string. Convert explicitly.

age = int(input("Age: "))       # string → int
price = float(input("Price: ")) # string → float
Enter fullscreen mode Exit fullscreen mode

šŸ”¤ 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
Enter fullscreen mode Exit fullscreen mode

⚔ f-Strings — The Modern Standard

user = "Arjun"
tokens = 1000

print(f"User: {user}, Max Tokens: {tokens}")
print(f"Score: {0.9534:.2f}")
Enter fullscreen mode Exit fullscreen mode

āœ… 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

2. Using = instead of ==

if age = 18:   # āŒ
Enter fullscreen mode Exit fullscreen mode

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_case naming 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.

Python #AI #Beginners #Programming

Top comments (0)