Python Environment Setup
In this page:
Interpreter Install करना
Official CPython interpreter, Windows, macOS और Linux के लिए python.org से मुफ़्त installer के रूप में उपलब्ध है।
खासकर Windows पर, installation के दौरान "Add python.exe to PATH" को tick करना वह step है जो शुरुआती लोग सबसे ज़्यादा भूलते हैं, और इसे छोड़ने का मतलब है कि बाद में आपके terminal में python command पहचानी नहीं जाएगी।
उदाहरण: Installing the Interpreter
# Download the installer from python.org
# On Windows, check "Add python.exe to PATH" during setup
print("Python interpreter installed and ready")
Text Editors और IDEs
लोकप्रिय विकल्पों में Python extension वाले VS Code जैसे हल्के code editors, Python का अपना bundled IDLE editor, और PyCharm जैसे पूर्ण-विशेषता वाले IDEs शामिल हैं, जो debugging और refactoring के tools जोड़ते हैं।
आप कौन सा चुनते हैं, यह उतना मायने नहीं रखता जितना कि कोई एक चुनकर उसके shortcuts में सहज हो जाना।
उदाहरण: Text Editors and IDEs
# Popular editors: VS Code (with Python extension), IDLE, PyCharm
print("Pick an editor and get comfortable with it")
अपना Code लिखना
Python source files की extension .py होती है, ताकि आपका editor और interpreter दोनों उन्हें चलाने योग्य Python code के रूप में पहचानें। फ़ाइल लिखने के लिए कोई भी सादा text editor चल जाता है — Python program बनाने वाली चीज़ editor नहीं, extension है।
उदाहरण: Writing Your Code
# Save this file as hello.py
print("The .py extension marks this as Python source code")
अपना Code चलाना
अपने terminal में, उस फ़ोल्डर के अंदर जिसमें फ़ाइल है, python filename.py (या कई Linux/macOS systems पर python3) चलाने से script interpreter को सौंप दी जाती है, जो उसे line-by-line execute करता है।
अगर command नहीं मिलती, तो आमतौर पर इसका मतलब है कि installation के दौरान का PATH वाला step छूट गया था।
उदाहरण: Running Your Code
# Run from your terminal:
# python filename.py
print("Executed line by line by the interpreter")
Setup की जाँच
कोई जटिल चीज़ लिखने से पहले, एक line की print("hello") script चलाने से पुष्टि हो जाती है कि interpreter सही से install है और आपका terminal सही फ़ाइल की ओर इशारा कर रहा है।
किसी मामूली चीज़ पर setup की समस्याएँ पकड़ने से बाद में भ्रम से बचाव होता है, जब असली bug और टूटा हुआ environment एक जैसे दिखने लगते हैं।
उदाहरण: Verifying the Setup
print("hello")
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: