3. Python Basics for Data Work
3.1 Variables and Types
Quick answer: the short, self-contained version of this lesson is the guide Python for Data Science: Beginner First Steps.
city = "Pune" # str
orders_today = 212 # int
gmv = 1_25_450.75 # float (underscores OK in Python 3.6+)
is_festival = True # bool
print(type(city), type(gmv))
f-strings build readable messages:
print(f"{city} GMV today: ₹{gmv:,.2f}")
# Pune GMV today: ₹125,450.75
Note: Python’s :, uses international thousands separators. For full Indian lakh format in reports you often format manually later; for class, :,.2f is fine.
Ravindra Bagale's Tip
If you write gmv = "125450" with quotes, Python stores it as text, not as a number. Then gmv + 100 gives a TypeError, and adding two such texts only joins them side by side. Keep numbers without quotes, and check with type(gmv) before you do any maths.
Ravindra Bagale's Tip – मराठी
gmv = "125450" असं quotes सोबत लिहिलं तर Python ते number म्हणून नाही तर text म्हणून ठेवतो. मग gmv + 100 केल्यावर TypeError येतो, आणि असे दोन text जोडले तर ते फक्त एकमेकांना चिकटतात. Numbers quotes शिवाय लिहा, आणि कोणतंही गणित करण्याआधी type(gmv) ने तपासा.
Ravindra Bagale's Tip – हिंदी
gmv = "125450" ऐसे quotes के साथ लिखोगे तो Python उसे number नहीं, text की तरह रखता है। फिर gmv + 100 करने पर TypeError आता है, और ऐसे दो text जोड़ने पर वे बस एक-दूसरे से चिपक जाते हैं। Numbers को बिना quotes के लिखो, और कोई भी गणित करने से पहले type(gmv) से जाँच लो।