Python Basics
NumPy, Pandas, scikit-learn — මේ හැම library එකක්ම යටින් තියෙන්නෙ සරල Python. මූලික දේවල් හරියට නැත්නම්, පස්සේ එන error messages ටිකත් clue එකක් නෙවෙයි, mystery එකක් වගේ පේනවා.
Every ML library — NumPy, Pandas, scikit-learn — is just Python underneath. If the basics are shaky, every error message later looks like magic instead of a clue.
Lesson 2 of 64 · Part 1 · Python & Data Basics · Python Fundamentals · bilingual notes (English + සිංහල)
Why this matters. Every ML library — NumPy, Pandas, scikit-learn — is just Python underneath. If the basics are shaky, every error message later looks like magic instead of a clue.
සිංහලෙන්: NumPy, Pandas, scikit-learn — මේ හැම library එකක්ම යටින් තියෙන්නෙ සරල Python. මූලික දේවල් හරියට නැත්නම්, පස්සේ එන error messages ටිකත් clue එකක් නෙවෙයි, mystery එකක් වගේ පේනවා.
What you'll use this for. You'll use variables and print statements in literally every notebook in this course — this is the one lesson you cannot skip.
සිංහලෙන්: මේ පාඨමාලාවේ හැම notebook එකකම variables සහ print statements පාවිච්චි වෙනවා — මේ තමයි මග හැරෙන්න බැරි එකම පාඩම.
Key principles
- Variables are just labelled boxes.
x = 10doesn't do maths — it puts the value 10 in a box named x, so you can use it later without retyping it.
Variables කියන්නෙ label කරපු boxes විතරයි - print() is how Python talks back to you. Code that runs silently could be doing anything. print() is your first, simplest debugging tool.
print() කියන්නෙ Python ඔයාට කතා කරන විදිහ
Walkthrough
Programming Languages used for Machine Learning:
- Python
- R
#print function
print("Machine Learning")Output
Machine Learningprint("Machine Learning" + " Projects")Output
Machine Learning Projectsprint(8)Output
8print(8+3)Output
11#Basic Data types:
- int
- float
- str
type(8)Output
inttype(5.3)Output
floattype("english")Output
str#Constants & Variables
marvel_super_hero = "Iron Man"
print(marvel_super_hero)Output
Iron Manmarvel_super_hero = "Captain America"
print(marvel_super_hero)Output
Captain Americahero1 , hero2 , hero3 = "Iron Man" , "Captain America" , "Bat Man"
print(hero1)
print(hero2)
print(hero3)Output
Iron Man
Captain America
Bat Manx = y = z = 23
print(x)
print(y)
print(z)Output
23
23
23input Function
number_1 = int(input("Enter the first number : "))
number_2 = int(input("Enter the second number : "))
sum = number_1 + number_2
print(sum)Output
Enter the first number : 23
Enter the second number : 23
46# changing the data type in python:
num = 5
print(float(num))Output
5.0Keep going: ← Lesson 1 · Lesson 3 → · Track it in the Self Guide
Finished this one?
Part of Self Guide · Stage 13: ML 1 — Python & Data Basics. Progress is saved in this browser.



