DEV Community

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

Posted 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)