1. Learning Outcomes#
या chapter नंतर तुम्हाला:
- Python ची सुरुवात कशी झाली ते समजेल
- Python कोणी तयार केली आणि त्यामागचा मुख्य विचार काय होता ते समजेल
- Python च्या major versions कशा बदलत गेल्या ते समजेल
- software मध्ये
versionम्हणजे काय ते समजेल - Python 2 आणि Python 3 मधील मुख्य फरक समजतील
- आज नवीन development साठी Python 3 का वापरली जाते ते समजेल
- जुना Python 2 code दिसल्यास तो ओळखता येईल
- Python version check कशी करायची ते समजेल
2. Python ची गोष्ट कुठून सुरू झाली?#
आज Python ही जगभर वापरली जाणारी programming language आहे.
Web Development, Automation, Data Science, Machine Learning, Testing, Scripting अशा अनेक कामांसाठी Python वापरली जाते.
पण सुरुवातीपासून Python इतकी मोठी language नव्हती.
या गोष्टीची सुरुवात होते Guido van Rossum यांच्यापासून.
1980 च्या दशकाच्या शेवटी Guido एका नवीन programming language वर विचार करत होते.
त्यांना अशी language हवी होती जी:
- code लिहायला तुलनेने सोपी असेल
- code वाचायला सोपा असेल
- developer ला छोट्या कामासाठी खूप boilerplate लिहावा लागणार नाही
- scripting आणि general programming दोन्हीसाठी उपयोगी पडेल
म्हणजे विचार साधा होता:
Programming powerful असावे, पण unnecessarily painful नसावे.
थोडक्यात, developer ने program लिहायचा की syntax सोबत कुस्ती करायची?
Python ने पहिला पर्याय निवडला.
3. Python कधी तयार झाली?#
Guido van Rossum यांनी Python वर काम साधारण 1989 मध्ये सुरू केले.
1991 मध्ये Python ची सुरुवातीची public version उपलब्ध झाली.
यामध्ये त्या काळासाठी महत्त्वाचे programming concepts उपलब्ध होते, जसे functions, classes, exceptions आणि basic data structures.
Python एका दिवसात पूर्ण झालेली language नाही.
ती अनेक वर्षे बदलत आणि सुधारत गेली.
हा development flow असा समजू शकतो:
Rendering diagram…
Diagram could not be rendered.
या flow मध्ये मुख्य गोष्ट notice करा:
Python 1 पासून थेट आजच्या Python 3 पर्यंत एका उडीत आली नाही.
Language च्या गरजा बदलल्या.
Developers च्या गरजा बदलल्या.
Programming जग बदलले.
त्यामुळे Python सुद्धा versions मधून evolve झाली.
Programming language ची नवीन version म्हणजे फक्त नवीन number नाही. त्या version मध्ये bugs fix होऊ शकतात, features add होऊ शकतात आणि language चे काही behavior सुधारले जाऊ शकते.
4. Python नाव कुठून आले?#
इथे एक मजेशीर गोष्ट आहे.
Python नाव सापामुळे ठेवले गेले असे अनेक beginners ना वाटते.
पण Guido van Rossum यांनी हे नाव British comedy show Monty Python's Flying Circus वरून घेतले.
म्हणजे Python शिकताना laptop जवळ साप ठेवण्याची आवश्यकता नाही.
Language च्या नावामागे comedy आहे, reptile नाही.
5. Definition#
A software version identifies a particular release or stage of development of a software product or programming language.
Version म्हणजे software किंवा programming language ची एखादी विशिष्ट release.
Software मध्ये सुधारणा झाल्यानंतर नवीन release येऊ शकते. त्या release ला ओळखण्यासाठी version number वापरला जातो.
उदाहरणार्थ:
Python 2.7
Python 3.8
Python 3.11
Python 3.xयेथील numbers आपल्याला कोणती Python release वापरली जात आहे याची माहिती देतात.
6. Version ची गरज काय?#
समजा तुमच्या mobile मध्ये एखादे application आहे.
आज त्याची एक version आहे.
काही महिन्यांनी company:
- bugs fix करते
- performance सुधारते
- नवीन features देते
- security सुधारते
आणि नवीन version release करते.
Programming language बाबतीतही broadly अशीच कल्पना लागू होते.
Language evolve होताना नवीन versions येतात.
नवीन version आली म्हणजे आधीची प्रत्येक गोष्ट चुकीची होती असा अर्थ नाही. नवीन version language ला पुढे घेऊन जाण्यासाठी improvements आणते.
7. Python च्या Major Version Generations#
Python च्या history मध्ये beginner ने मुख्यतः तीन generations लक्षात ठेवाव्यात:
Python 1.x#
Python 1.0 ही सुरुवातीच्या major releases पैकी एक होती.
या काळात Python ची basic language foundation विकसित होत होती.
आजच्या beginner ला Python 1 वापरून development करण्याची गरज नाही.
Python चा evolution समजण्यासाठी तिचे historical महत्त्व आहे.
Python 2.x#
Python 2.0 सन 2000 मध्ये release झाली.
Python च्या adoption मध्ये Python 2 generation ची मोठी भूमिका होती.
अनेक applications, scripts आणि libraries Python 2 वापरून तयार करण्यात आल्या.
त्यामुळे अनेक वर्षे Python 2 मोठ्या प्रमाणावर वापरली गेली.
पण software ecosystem पुढे जात असताना language मध्ये काही जुन्या design decisions सुधारण्याची गरज निर्माण झाली.
त्यातून Python 3 आली.
Python 3.x#
Python 3.0 सन 2008 मध्ये release झाली.
Python 3 मध्ये language चे काही behavior अधिक consistent आणि future-friendly करण्यासाठी बदल करण्यात आले.
पण इथे एक महत्त्वाची गोष्ट होती.
Python 3 मधील काही changes Python 2 सोबत पूर्णपणे backward compatible नव्हते.
Backward compatible म्हणजे काय?
सोप्या भाषेत:
जुन्या version साठी लिहिलेला code नवीन version मध्ये कोणताही बदल न करता चालेल का?
Python 2 चा प्रत्येक program Python 3 मध्ये तसाच चालेल याची guarantee नव्हती.
त्यामुळे Python 2 वरून Python 3 कडे transition एका दिवसात झाली नाही.
अनेक projects हळूहळू migrate झाले.
Rendering diagram…
Diagram could not be rendered.
इथे learner ने एवढे समजून घ्यायचे आहे:
Python 3 ही फक्त Python 2 चे नाव बदलून केलेली release नव्हती.
काही language behavior मध्ये वास्तविक changes झाले होते.
8. Python 2 vs Python 3#
आता दोन्ही versions मधील काही beginner-level फरक पाहू.
सगळे historical differences पाठ करण्याची गरज नाही.
जे differences जुना code समजताना उपयोगी पडतात ते समजून घेणे महत्त्वाचे आहे.
9. print वापरण्याची पद्धत#
Python 2 मध्ये print सामान्यतः statement सारखे वापरले जात होते.
Python 2 style:
print "Hello"Python 3 मध्ये print() function आहे.
Python 3:
print("Hello")Expected Output#
HelloPython 3 code मध्ये Hello ही value print() function ला दिली जाते.
मग print() ती screen वर दाखवते.
आज तुम्ही नवीन Python code लिहित असाल तर Python 3 syntax वापराल:
print("Hello")Internet वर खूप जुना tutorial पाहताना print "Hello" असा code दिसू शकतो. तो modern Python 3 syntax समजू नका.
10. Integer Division मधील फरक#
हा फरक जुना code वाचताना विशेष लक्षात ठेवण्यासारखा आहे.
Python 2 मध्ये:
5 / 2दोन integers वापरल्यास result:
2असा मिळू शकत होता.
Python 3 मध्ये:
print(5 / 2)Expected Output#
2.5Python 3 मध्ये / normal division करते.
म्हणून 5 ला 2 ने divide केल्यावर actual fractional result 2.5 मिळतो.
जर Python 3 मध्ये integer-style floor division हवी असेल तर // operator वापरता येतो:
print(5 // 2)Expected Output#
2इथे // मुळे fractional portion result मध्ये ठेवला जात नाही.
Python 2 आणि Python 3 code दिसायला जवळचा असला तरी काही expressions चे behavior वेगळे असू शकते.
11. Text handling#
Computer ला English पुरतेच जग नसते.
मराठी, हिंदी, जपानी, Arabic आणि इतर भाषांमधील text सुद्धा handle करावा लागतो.
Python 2 च्या काळात str आणि Unicode text हाताळताना developer ला जास्त काळजी घ्यावी लागत असे.
Python 3 मध्ये सामान्य text handling Unicode-oriented करण्यात आले.
Beginner म्हणून आत्ता तुम्हाला encoding चे internals शिकायची गरज नाही.
फक्त ही कल्पना लक्षात ठेवा:
Python 3 मध्ये modern international text handling अधिक natural करण्यात आले.
उदाहरण:
name = "दत्तात्रय"
print(name)Expected Output#
दत्तात्रयया example मध्ये Python string मध्ये Marathi text ठेवला आहे आणि तो print केला आहे.
12. Python 2 support का बंद झाली?#
एका मोठ्या software project मध्ये दोन major generations कायम maintain करणे कठीण असते.
Developers ना:
- Python 2 maintain करायची
- Python 3 improve करायची
- libraries दोन्हीकडे support करायच्या
- bugs आणि security concerns handle करायचे
असे दुहेरी काम करावे लागत होते.
Python ecosystem पुढे Python 3 वर focus करू शकावा म्हणून Python 2 चे official support बंद करण्यात आले.
Python 2.7 ही Python 2 series मधील शेवटची major release होती.
Python 2 साठी official support 1 January 2020 रोजी समाप्त झाले.
Rendering diagram…
Diagram could not be rendered.
या diagram मध्ये मुख्य विचार असा आहे:
Python 3 release होताच Python 2 गायब झाली नाही.
दोन्ही काही काळ वापरात होत्या.
Projects migrate झाले.
नंतर Python 2 चे official support बंद झाले आणि modern development Python 3 कडे केंद्रित झाले.
"जुने ते सोने" हे ठीक आहे; पण unsupported production technology फक्त जुनी आहे म्हणून वापरणे योग्य strategy नसते.
13. आज beginner ने कोणती Python शिकावी?#
नवीन learner ने Python 3 शिकावी.
तुम्ही पुढे examples पाहाल ते Python 3 style वर आधारित असतील.
जर तुम्हाला एखाद्या company मध्ये खूप जुना project मिळाला तर Python 2 code भेटू शकतो.
त्या वेळी history समजल्याचा फायदा होतो.
तुम्हाला लगेच लक्षात येऊ शकते:
"हा code विचित्र नाही; हा बहुधा जुन्या Python version चा आहे."
हा फरक महत्त्वाचा आहे.
नाहीतर beginner जुना Python 2 code पाहून स्वतःच्या Python 3 installation ला दोष देतो.
Computer मनात म्हणत असतो:
"माझी काय चूक? Tutorial 2012 चा आहे!"
14. Installed Python Version कशी check करायची?#
System वर installed Python version command line मधून check करता येते.
सामान्य command:
python --versionकाही systems वर:
python3 --versionOutput उदाहरण:
Python 3.x.xExact number तुमच्या system वर installed version वर अवलंबून असेल.
आपण काय check केले?#
आपण Python program लिहिलेला नाही.
आपण Python executable ला त्याची version माहिती दाखवण्यास सांगितले.
--version option चा purpose म्हणजे installed Python release ओळखणे.
15. Version number पाहताना काय समजायचे?#
उदाहरण म्हणून:
Python 3.12.4असा version दिसला तर तो broadly तीन number parts मध्ये दिसतो:
3 . 12 . 4Beginner साठी एवढी कल्पना पुरेशी आहे:
3→ major generation12→ त्या generation मधील release line4→ त्यातील smaller update
याचे package-management-level किंवा release-policy-level details आत्ता आवश्यक नाहीत.
मुख्य मुद्दा:
Python 2.x आणि Python 3.x मधील major number बदल language च्या इतिहासात खूप महत्त्वाचा होता.
16. Python 2 code ओळखण्याचा छोटा संकेत#
समजा तुम्हाला खालील code सापडला:
print "Welcome"Python 3 शिकणाऱ्या beginner ला वाटू शकते:
"अरे, print() चे brackets कुठे गेले?"
हीच history समजण्याची practical value आहे.
हा code पाहून तुम्ही suspect करू शकता की तो Python 2 style code आहे.
Python 3 style:
print("Welcome")जुना code दिसला म्हणजे लगेच तो copy-paste करून चालवू नका. तो कोणत्या Python version साठी लिहिला आहे हे तपासा.
17. Python versions का महत्त्वाच्या आहेत?#
Version माहिती फक्त interview question नाही.
Real project मध्ये ती practical असते.
समजा project documentation म्हणते:
Requires Python 3.xआणि developer incompatible version वापरत असेल.
तर application, library किंवा syntax संबंधित problems येऊ शकतात.
म्हणून professional development मध्ये:
- project ला required version समजून घ्या
- आपल्या system वर कोणती version आहे ते check करा
- project requirements सोबत compatibility verify करा
Version number हा decoration नसतो.
तो environment चा भाग असतो.
18. Python 2 आणि Python 3 — Quick Comparison#
| Point | Python 2 | Python 3 |
|---|---|---|
| Generation | Older generation | Current generation |
print |
print "Hello" style |
print("Hello") |
5 / 2 behavior |
Commonly 2 with integers |
2.5 |
| Text handling | Older string/Unicode model | Unicode-oriented text model |
| Official support | Ended | Used for modern Python development |
| New learner | Learn mainly for legacy recognition | Learn and use |
हा table पाठ करण्यासाठी नाही.
तो दोन generations ची mental picture तयार करण्यासाठी आहे.
19. Common Beginner Confusions#
Python 3 म्हणजे Python ची तिसरीच release आहे का?#
नाही.
3 हा major version number आहे.
Python 3 येण्यापूर्वी Python च्या अनेक releases झाल्या होत्या.
Python 2 अजून शिकावी लागेल का?#
नवीन Python development सुरू करण्यासाठी Python 2 शिकण्याची गरज नाही.
पण जुना code पाहताना Python 2 अस्तित्वात होती आणि तिची syntax/behavior काही ठिकाणी वेगळी होती हे माहित असणे उपयोगी आहे.
Python 2 code Python 3 मध्ये नेहमी चालतो का?#
नाही.
काही code चालू शकतो.
पण Python 2 आणि Python 3 पूर्णपणे backward compatible नाहीत.
म्हणून जुना project migrate करताना code changes आणि testing लागू शकते.
माझी Python version वेगळी असेल तर Python चुकीची आहे का?#
नाही.
Python 3 family मध्ये अनेक releases असतात.
Project ला specific version requirement आहे का हे पाहणे महत्त्वाचे आहे.
20. Hands-On Practice#
Practice 1#
Requirement
तुमच्या system वर installed Python version शोधा.
Your Task
Terminal किंवा Command Prompt मध्ये योग्य version command run करा.
HintShow Hint
python --versionकाम केले नाही तर:
python3 --versionSolutionShow Solution
Output साधारण असा दिसू शकतो:
Python 3.x.xExplanation
Exact version तुमच्या system वर अवलंबून आहे.
या activity चा उद्देश Python code लिहिणे नाही.
आपण कोणत्या Python environment सोबत काम करत आहोत हे ओळखणे हा उद्देश आहे.
Practice 2#
Requirement
खालील दोन code styles पाहा:
print "Hello"आणि:
print("Hello")Your Task
यापैकी modern Python 3 style कोणती ते ओळखा.
HintShow Hint
Python 3 मध्ये print function आहे.
SolutionShow Solution
print("Hello")Explanation
Python 3 मध्ये text print() function ला argument म्हणून दिला जातो.
Practice 3#
Requirement
Python 3 मध्ये खालील expression चा result विचार करा:
5 / 2Your Task
Result 2 येईल की 2.5?
HintShow Hint
Python 3 मधील / normal division करते.
SolutionShow Solution
2.5Explanation
5 ला 2 ने divide केल्यावर actual division result 2.5 आहे.
Python 3 मध्ये / हा fractional result preserve करतो.
21. Interview Preparation#
Who created Python and when was it first released?Show Answer
Python was created by Guido van Rossum. Development started around 1989, and an early public release became available in 1991.
Key Points:
- Creator: Guido van Rossum
- Development began around 1989
- Early public release: 1991
Why interviewer asks this:
This is a basic introductory question used to check whether the candidate understands the background of the language.
What is the main difference between Python 2 and Python 3?Show Answer
Python 3 is the modern generation of Python and introduced several language changes compared with Python 2. Examples include print() as a function, different division behavior, and improved Unicode-oriented text handling. Python 2 is no longer officially supported.
Key Points:
- Python 3 introduced language-level changes
- Python 2 and Python 3 are not fully backward compatible
- Python 2 official support has ended
- Modern development uses Python 3
Why interviewer asks this:
The interviewer wants to know whether the candidate can recognize legacy Python code and understands which generation is relevant for modern development.
How can you check the installed Python version?Show Answer
You can commonly check the installed Python version by running python --version or, depending on the environment, python3 --version in the command line.
Key Points:
- Use the command line
python --versionpython3 --versionmay be used on some systems
Why interviewer asks this:
Checking runtime versions is a basic development-environment skill.
22. या Chapter मधून काय लक्षात ठेवायचे?#
- Python चे creator Guido van Rossum आहेत.
- Python वर काम साधारण 1989 मध्ये सुरू झाले.
- सुरुवातीची public release 1991 मध्ये आली.
- Python अनेक versions मधून evolve झाली.
- Python 2 आणि Python 3 या दोन महत्त्वाच्या generations आहेत.
- Python 3 मध्ये Python 2 च्या तुलनेत काही language behavior बदलले.
- Python 2 चे official support 2020 मध्ये बंद झाले.
- नवीन development साठी Python 3 वापरली जाते.
- जुना Python 2 code भेटल्यास त्याची syntax Python 3 पेक्षा वेगळी असू शकते.
python --versionकिंवा environment नुसारpython3 --versionवापरून installed version check करता येते.
Python ची history पाठ करणे हा उद्देश नाही. Language कशी evolve झाली आणि जुना Python 2 code व modern Python 3 code वेगळा का दिसू शकतो हे समजणे हा मुख्य उद्देश आहे.