Type Here to Get Search Results !

DCA Programming and problem solving through python

0

1. Python की विशेषताएँ और लाभ | अन्य भाषाओं से अंतर

Python की विशेषताएँ (Features of Python)

  1. सिंपल और आसान भाषा

    • Python का सिंटैक्स बहुत सरल है। शुरुआती लोग आसानी से सीख सकते हैं।

  2. हाई-लेवल लैंग्वेज

    • हार्डवेयर-लेवल की जटिलताओं से दूर रखकर आसान प्रोग्रामिंग कराई जाती है।

  3. इंटरप्रिटेड भाषा

    • कोड लाइन-बाय-लाइन execute होता है, इसलिए errors जल्दी मिलते हैं।

  4. ऑब्जेक्ट-ओरिएंटेड प्रोग्रामिंग सपोर्ट

    • Class, Object, Inheritance, Polymorphism सब उपलब्ध हैं।

  5. पोर्टेबल और प्लेटफॉर्म-इंडिपेंडेंट

    • Windows, Linux, Mac—हर प्लेटफॉर्म पर चलता है।

  6. रिच लाइब्रेरी सपोर्ट

    • NumPy, Pandas, TensorFlow, Django, Flask जैसे हजारों मॉड्यूल उपलब्ध।


Python के लाभ (Advantages)

  • कोड लिखने और समझने में आसान

  • तेजी से विकास (Rapid Development)

  • डेटा साइंस, AI, मशीन लर्निंग में मुख्य भाषा

  • बड़ी कम्युनिटी और सपोर्ट


अन्य भाषाओं से अंतर

Pythonअन्य भाषाएँ (C, Java आदि)
कोड छोटा और readableकोड लंबा और complex
Interpreter-basedCompiler-based
Dynamic typingStatic typing
Memory management autoManual memory management
Libraries का विशाल collectionसीमित libraries

2. Python के डेटा प्रकार और वेरिएबल्स

मुख्य Data Types:

  1. Integer – पूर्णांकों के लिए

    a = 10
  2. Float – दशमलव संख्या

    b = 10.5
  3. String – पाठ/टेक्स्ट

    name = "Python"
  4. Boolean – True/False

    x = True
  5. List

  6. Tuple

  7. Dictionary

  8. Set


Variable Declaration Example

x = 5 y = 3.14 name = "Amit" print(x, y, name)

3. Python के विभिन्न प्रकार के ऑपरेटर

1. Arithmetic Operators

OperatorExampleMeaning
+5 + 3Addition
-5 - 2Subtraction
*4 * 2Multiplication
/10 / 2Division
%10 % 3Remainder
**2 ** 3Power

2. Relational/Comparison Operators

5 > 3 # True 5 == 5 # True

3. Logical Operators

a = True b = False print(a and b) print(a or b) print(not a)

4. Assignment Operators

x = 10 x += 5 # x = x + 5

4. if-else और Nested if-else

if-else Example

age = 18 if age >= 18: print("Eligible to vote") else: print("Not eligible")

Nested if-else Example

marks = 75 if marks >= 60: if marks >= 80: print("Grade A") else: print("Grade B") else: print("Grade C")

5. for loop और while loop | Fibonacci Program

अंतर (Difference)

for loopwhile loop
Range या sequence पर कार्य करता हैCondition true होने तक चलता है
Iteration count पता होता हैIteration count जरूरी नहीं

Fibonacci Series Program

n = 10 a, b = 0, 1 print(a, b, end=" ") for i in range(2, n): c = a + b print(c, end=" ") a = b b = c

6. Python Functions | Built-in vs User-defined

Function क्या है?

एक कोड ब्लॉक जो काम पूरा होने पर बार-बार उपयोग किया जा सके।


Built-in Functions

Python में पहले से बनाए हुए फंक्शन

print("Hello") len("Python")

User-defined Functions

जो हम खुद बनाते हैं

def greet(): print("Hello Students") greet()

7. Lists, Tuples और Dictionaries की तुलना

FeatureListTupleDictionary
MutabilityChangeableNot ChangeableChangeable
Brackets[](){}
UseData modify करना होFixed dataKey-value pair

Examples

list1 = [10, 20, 30] tuple1 = (1, 2, 3) dict1 = {"name": "Amit", "age": 20}

8. File Handling: Read/Write

File लिखना (Write)

f = open("data.txt", "w") f.write("Hello Python") f.close()

File पढ़ना (Read)

f = open("data.txt", "r") content = f.read() print(content) f.close()

9. Classes and Objects in Python

Concept

  • Class = Blueprint

  • Object = Class का वास्तविक उपयोग


Example Program

class Student: def show(self): print("This is a student class") obj = Student() obj.show()

10. Python Exceptions | try-except-finally

Exception क्या है?

Error आने पर प्रोग्राम को crash होने से रोकना।


try-except-finally Example

try: a = int(input("Enter number: ")) print(10 / a) except: print("Error occurred!") finally: print("Program completed")

Post a Comment

0 Comments

Top Post Ad

Bottom Post Ad

Show ad in Posts/Pages

WhatsApp