Python Basics Training
For Trainees - AI ODC
What is Python?
• High-level, interpreted programming language
• Easy to learn, readable, versatile
• Used in AI, ML, Data Science, Web,
Automation
Python Basics
• Print and Comments
• Variables and Data Types
• Input and Type Casting
• Operators
Conditionals
• If-Else statements
• Decision making in code
• Examples: Check age, even/odd number
Loops
• For loop
• While loop
• Iterating through lists and ranges
Functions
• Reusable blocks of code
• With and without parameters
• Examples: Square of a number, Calculator
function
Data Structures
• Lists – ordered, changeable
• Tuples – ordered, unchangeable
• Dictionaries – key-value pairs
• Sets – unique elements
Modules and Libraries
• import keyword
• Standard library (math, datetime, etc.)
• Third-party libraries (numpy, pandas, flask)
File Handling
• Read and write files
• with open() as ...
• Useful for logs, configs, data storage
Error Handling
• try-except blocks
• Avoid program crashes
• Handle invalid inputs or missing files
Practice Exercises
• Print your name and age
• Check if a number is even or odd
• Write a function to calculate factorial
• Create a dictionary of 3 students with marks
• Read and write to a file