Now we need to learn basics of python . Not deeply but only what needed to AI/ML. Today session also we divided into 3 parts:
Part-1 : Python Basics for Developers
1️⃣ Variables
C#:
int age = 30;
string name = "Test";
Python:
age = 30
name = "Test"
👉 No type declaration. Dynamic typing.
2️⃣ Lists (Like C# List<T>)
Python:
numbers = [1, 2, 3, 4]
names = ["UT", "AI", "Engineer"]
Access:
print(numbers[0])
Loop:
for num in numbers:
print(num)
3️⃣ Dictionaries (Like C# Dictionary<TKey, TValue>)
Python:
user = {
"name": "UT",
"age": 30
}
print(user["name"])
4️⃣ Functions
C#:
string Greet(string name)
{
return $"Hello {name}";
}
Python:
def greet(name):
return f"Hello {name}"
print(greet("Test"))
5️⃣ If-Else
Python:
if age > 18:
print("Adult")
else:
print("Minor")
Indentation = Important in Python ⚠
Part-2 : Virtual Environment + Packages
1️⃣ Create Virtual Environment
Open terminal:
python -m venv venv
Activate:
Windows:
venv\Scripts\activate
2️⃣ Install Packages
pip install numpy pandas matplotlib scikit-learn jupyter
These are core ML libraries.
3️⃣ Start Jupyter Notebook
jupyter notebook
Create:
day2_python_basics.ipynb
OR
Another best option is - If you dont want to install anything on your laptop or if you want to practice on your office laptop then use Google Colab - which is browser specific & best for running python code, that requires no setup and runs entirely in the cloud.
For more info watch this Video: https://youtu.be/0N0NuVKWhDA
Part 3 - Mini Practice
Inside Jupyter or Colab, write this:
Task-1 :
Create list of numbers 1–10
Print only even numbers
Task-2
Create dictionary:
student = {
"name": "UT",
"marks": [80, 85, 90]
}
Calculate average marks.
Task-3
Create function:
Takes list
-
Returns sum
🎯 End of Day-2 Deliverables
✅ Python installed
✅ Virtual environment created
✅ Jupyter running
✅ Basic script written
✅ Pushed to GitHub (Week1 folder)
0 Comments
If you have any queries, please let me know. Thanks.