Python Sample Code for Beginners: 15 आसान Python Programs (हिंदी में)
संक्षिप्त जवाब: Python सीखने का सबसे तेज तरीका है छोटे-छोटे programs खुद लिखकर run करना। Beginners को Hello World, दो numbers का sum, even-odd, leap year, factorial और multiplication table जैसे programs से शुरू करना चाहिए। इनसे syntax, input/output, conditions और loops, चारों basics एक साथ पक्के हो जाते हैं। इस blog में ऐसे 15 programs output और explanation के साथ दिए गए हैं।
Python दुनिया की सबसे popular और beginner-friendly programming languages में से एक है। इसकी syntax लगभग English जैसी पढ़ने में आसान है, इसलिए नए learners इसे जल्दी पकड़ लेते हैं। लेकिन सिर्फ theory पढ़ने से programming नहीं आती। असली सीख तब होती है जब आप छोटे programs खुद type करके run करते हैं।
लेखक: Ms. Sonal · Category: Python Programming · पढ़ने का समय: 13 मिनट
इस लेख में आप सीखेंगे
साथ ही: Python से जुड़े common FAQs।
Simple Python Programs से शुरुआत क्यों करें?
छोटे programs लिखने से आप एक साथ कई जरूरी चीजें सीखते हैं:
- Syntax और Indentation: Python में indentation (space) से code blocks बनते हैं, यह आदत शुरू में ही पक्की होती है।
- Loops और Conditions: for, while, if-else का practical use समझ आता है।
- Functions: Code को reusable बनाने की सोच विकसित होती है।
- Input और Output: User से data लेना और result दिखाना सीखते हैं।
- Debugging: Errors पढ़ना और उन्हें ठीक करना आता है।
Beginners के लिए 10 Simple Python Programs
1Greeting Print करना (Hello World)
Output:
Explanation: print() function screen पर text दिखाता है। Text को हमेशा quotes (" ") में लिखा जाता है। यह हर language का पहला program होता है।
2दो Numbers का Sum
Output:
Explanation: a और b variables में values रखी गई, + operator से जोड़ा गया और result total में store हुआ। Python में variable का type बताना नहीं पड़ता।
3User से Input लेना
Output:
Explanation: input() user से keyboard input लेता है और उसे हमेशा string (text) के रूप में return करता है।
4किसी Number का Square निकालना
Output:
Explanation: int() input string को integer में बदलता है। ** power operator है, यानी num ** 2 का मतलब num².
5Even या Odd Check करना
Output:
Explanation: % (modulus) remainder देता है। अगर number को 2 से भाग देने पर remainder 0 है, तो number even है, वरना odd।
6दो Numbers में बड़ा Number ढूँढना
Output:
Explanation: if - elif - else से तीनों cases (a बड़ा, b बड़ा, दोनों बराबर) handle होते हैं।
7दो Variables को Swap करना
Output:
Explanation: Python में tuple unpacking (x, y = y, x) से बिना तीसरे variable के swap हो जाता है। C या Java में इसके लिए temp variable चाहिए होता है।
8Leap Year Check करना
Output:
Explanation: Leap year वह साल है जो 4 से divisible हो लेकिन 100 से नहीं, या फिर 400 से divisible हो। इसीलिए 1900 leap year नहीं है, लेकिन 2000 था।
91 से 10 तक Numbers Print करना
Output:
Explanation: range(1, 11) 1 से 10 तक numbers देता है (आखिरी value 11 शामिल नहीं होती)। end=" " से हर number एक ही line में space के साथ print होता है।
10Factorial निकालना
Output:
Explanation: Factorial (n!) = 1 × 2 × 3 × ... × n। Loop हर number को fact से multiply करता जाता है। 5! = 120।
Hands-On Examples से सीखना क्यों जरूरी है?
- Syntax याद रहती है: बार-बार type करने से syntax अपने आप याद हो जाती है।
- Practical समझ बनती है: Concept किताब से नहीं, output देखकर समझ आता है।
- Logical thinking बढ़ती है: हर program एक छोटी problem है, जिसे solve करना logic की practice है।
5 Extra Practice Programs
11Vowel या Consonant Check करना
Output:
Explanation: .lower() से capital letter भी small बन जाता है, फिर in operator check करता है कि letter "aeiou" में है या नहीं।
12Digits का Sum निकालना
Output:
Explanation: % 10 से last digit मिलता है और // 10 (floor division) से last digit हट जाता है। 1 + 2 + 3 + 4 = 10।
13String को Reverse करना
Output:
Explanation: [::-1] slicing है, जो string को पीछे से आगे की तरफ पढ़ता है। यह Python का सबसे छोटा reverse trick है।
14Sentence में Words गिनना
Output:
Explanation: split() sentence को spaces पर तोड़कर words की list बनाता है, और len() उस list की length देता है।
15Multiplication Table (पहाड़) Print करना
Output:
Explanation: Loop 1 से 10 तक चलता है और हर बार number को i से multiply करके print करता है।
Quick Revision: कौन सा Program क्या सिखाता है?
| Program | Concept |
|---|---|
| Hello World, Greeting | print() function, strings |
| Sum, Square | Variables, arithmetic operators, ** operator |
| User Input | input(), int() type conversion |
| Even-Odd, Larger Number, Leap Year | if-elif-else, % operator, logical operators (and, or) |
| Swap | Tuple unpacking |
| 1 to 10, Factorial, Table | for loop, range() |
| Sum of Digits | while loop, %, // |
| Vowel-Consonant | in operator, .lower(), strings |
| Reverse String | String slicing [::-1] |
| Word Count | split(), len(), lists |
Absolute Beginners के लिए Python Tips
- रोज़ practice करें: रोज़ 30 से 60 मिनट coding, हफ्ते में एक बार 5 घंटे से बेहतर है।
- Error messages पढ़ना सीखें: Python का error message अक्सर बता देता है कि गलती किस line में और क्या है।
- Online IDE use करें: शुरुआत में installation की झंझट न हो तो Replit या Google Colab जैसे online editors use करें।
- छोटे projects बनाएं: हर नया concept सीखने के बाद उससे एक छोटा tool बनाने की कोशिश करें।
- Structured course लें: Random videos की जगह एक step-by-step roadmap follow करें।
Daily Life में Simple Python Programs के Uses
- Basic automation: Files rename करना, folders organize करना।
- Data handling: Marks, expenses या attendance का हिसाब रखना।
- Math helpers: EMI, interest, percentage जैसे calculations।
- Text processing: Words गिनना, text clean करना, keywords ढूँढना।
Beginners के लिए Python Project Ideas
- Simple Calculator: +, -, ×, ÷ operations के साथ (if-else और functions की practice)।
- Quiz Game: सवाल पूछे और score बताए (lists और loops)।
- Text-based To-Do List: Task add, delete और view करना (lists और menus)।
- Number Guessing Game: random module से एक number चुने और user को guess करवाएं।
Python Programs से जुड़े FAQs
Q1. Beginners के लिए सबसे आसान Python programs कौन से हैं?
Hello World, दो numbers का sum, even-odd check, बड़ा number ढूँढना, leap year, factorial और multiplication table सबसे आसान और जरूरी starting programs हैं।
Q2. क्या ये simple programs interviews के लिए काफी हैं?
नहीं। ये programs basics मज़बूत करते हैं, लेकिन interviews के लिए problem-solving और Data Structures and Algorithms (DSA) जैसे topics भी सीखने ज़रूरी हैं।
Q3. Basics के बाद Python में आगे कैसे बढ़ें?
छोटे projects बनाएँ, Tkinter या Pandas जैसी libraries explore करें, और LeetCode या HackerRank जैसे platforms पर coding challenges solve करें।
Q4. Python सीखने में कितना समय लगता है?
Regular practice के साथ basics लगभग 1 से 2 महीने में आ जाते हैं, और अच्छी proficiency के लिए आमतौर पर 4 से 6 महीने लगते हैं।
Q5. Python में input() से number कैसे लें?
input() हमेशा string return करता है, इसलिए number के लिए
int(input()) या decimal के लिए float(input()) लिखें।
Q6. क्या Uncodemy का Python course beginners के लिए सही है?
हाँ। Course बिल्कुल basics से शुरू होता है और धीरे-धीरे advanced topics, projects और placement preparation तक ले जाता है।
Q7. क्या Python course के बाद job मिल सकती है?
Uncodemy के course में placement support, mock tests, live projects और resume help मिलती है। Job आपकी skills और practice पर भी निर्भर करती है।
Key Takeaways
- Python सीखने का सबसे अच्छा तरीका छोटे programs खुद लिखकर run करना है।
- input() हमेशा string देता है, numbers के लिए int() या float() से convert करें।
- % remainder देता है, // floor division करता है और ** power निकालता है।
- इन 15 programs से variables, conditions, loops और strings, सब cover हो जाते हैं।
- Basics के बाद projects और DSA की तरफ बढ़ें।
निष्कर्ष (Conclusion)
Python में मजबूत पकड़ बनाने के लिए consistency सबसे ज़रूरी है। ऊपर दिए 15 programs रोज़ एक-दो करके practice करें, फिर उनमें छोटे बदलाव करके देखें (जैसे table की 20 तक ले जाना, या factorial की function में बदलना)। जब ये programs आपको बिना देखें लिखने आ जाएँ, तब छोटे projects शुरू करें।
Python को structured तरीके से, projects और placement support के साथ सीखना चाहते हैं? Uncodemy का Python Course देखें।
Related Hindi Guides
नीचे दिए Hindi pages live होने के बाद इस blog में contextual links जोड़ें — जो page अभी live नहीं है, उसका link न डालें (404 से बचें)।
| Topic | Planned URL |
|---|---|
| Python for Loop | /hi/blog/python-for-loop-with-examples |
| Python में Prime Number | /hi/blog/python-code-to-check-prime-number |
| Armstrong Number | /hi/blog/what-is-armstrong-number-definition-and-c-program |
| DSA Guide | /hi/blog/what-is-dsa-data-structures-and-algorithms-complete-guide
|
Visit Us
- Delhi Centre Address
- 2nd & 3rd Floor, Maa Katyayni Complex, MB-1E, Madhuban Rd, next to DSEU Ambedkar College, Laxmi Nagar, Shakarpur Extension, Shakarpur, Delhi, 110092
- Opening hours
- Monday – Sunday, 06:00 – 22:30
- Phone
- +91 9818366550, +91 8766313646
- info@uncodemy.com
- Website
- uncodemy.com