Lesson 03 � Foundation

VALUE KA
NATURE SAMJHO.

Har value same tarah behave nahi karti. 25 ko add kar sakte ho; "25" text hai. Type samajhna bugs se bachne aur right operation choose karne ka shortcut hai.

? 20 min✓ BeginnerPrerequisite: Variables

WHAT: four daily-use types

int

Whole number: items = 8. Count, rank aur quantity ke liye.

float

Decimal number: rating = 4.7. Price, percentage aur measurements ke liye.

str

Text: city = "Lucknow". Quotes ke andar ki value.

bool

True ya False: is_paid = False. Yes/no state aur decisions ke liye.

WHY: operation value se nahi, type se decide hota hai

python
print(2 + 3) # 5, number addition
print("2" + "3") # 23, text joining

price = 499
discount = 0.10
final_price = price * (1 - discount)
print(final_price) # 449.1

type() is aapka inspection tool: doubt ho to Python se directly poochho ki value kis type ki hai.

Try it: type detectiveValues change karke observe karo
Run Python dabayein

Casting: consciously type convert karo

Kabhi data text form mein milta hai, lekin calculation ke liye number chahiye. int(), float() aur str() intentional conversion karte hain.

python
marks_from_form = "88"
marks = int(marks_from_form)

print(marks + 12) # 100
print("Score: " + str(marks))
!
Conversion validate bhi karni hoti hai. int("eighty") error dega, kyunki text valid integer format mein nahi hai. Later exceptions module mein isi ko gracefully handle karoge.

Quick check

Integer 10 ko decimal/float mein convert karne ki valid expression likho.

Float banane wala built-in function yaad karo.

Common mistakes

Data type intuition build ho gayi?

Ab strings ko deeply dekho�text Python mein sequence bhi hai, sirf sentence nahi.