← Back to Python Course | Chapter 1: Basics | Lesson 3 of 14

Python Environment Setup

Python को सेटअप करना एक नए गेम कंसोल को खोलने जैसा है: आप इसे install करते हैं, कोड लिखने की जगह जोड़ते हैं, और जाँचते हैं कि यह चालू होता है। उसके बाद आप खेलने के लिए तैयार हैं।

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

python
# 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

python
# 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

python
# 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

python
# 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

python
print("hello")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.