0% found this document useful (0 votes)
2 views

Introduction to Python

Python is a high-level, interpreted programming language ideal for beginners, used in web development, data science, AI, and automation. Key features include simplicity, dynamic typing, and a large community with extensive libraries. The document covers installation, basic syntax, data types, input/output, operators, conditional statements, loops, functions, file handling, exception handling, and object-oriented programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction to Python

Python is a high-level, interpreted programming language ideal for beginners, used in web development, data science, AI, and automation. Key features include simplicity, dynamic typing, and a large community with extensive libraries. The document covers installation, basic syntax, data types, input/output, operators, conditional statements, loops, functions, file handling, exception handling, and object-oriented programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Introduction to Python (परिचय)

Python ek high-level, interpreted aur easy-to-learn programming language hai. Yeh beginners ke liye best hai
aur iska use web development, data science, AI, automation, aur bohot jagah hota hai.

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

1. Simple aur Easy to Learn - Python ka syntax simple aur readable hota hai.

2. Interpreted Language - Code ko bina compile kiye direct run kar sakte hain.

3. Dynamically Typed - Variable declare karne ka koi zor nahi, direct assign kar sakte hain.

4. Platform Independent - Windows, Mac, Linux sab pe chal sakta hai.

5. Large Community & Libraries - Pehle se bohot saari libraries available hain.

Python Installation (इं स्टॉलेशन)

Python install karne ke liye aap Python की official website se download kar sakte hain. Phir python --version
command se verify karein.

Installation ke baad aap IDLE ya Jupyter Notebook use karke coding start kar sakte hain. Python ko run karne
ke liye command prompt (cmd) me python likh ke enter karein.

Python Basics (बेविक्स)

1. Variables & Data Types (िेरिएबल औि डे टा टाइप)

Variables kisi bhi data ko store karne ke liye use hote hain.

x = 10 # Integer

y = 10.5 # Float

name = "Ram" # String

is_active = True # Boolean

Common Data Types:

Data Type Example

Integer 10

Float 10.5

String "Hello"
Data Type Example

Boolean True / False

List [1, 2, 3]

Tuple (1, 2, 3)

Dictionary {"name": "Ram", "age": 20}

Set {1, 2, 3}

Aap type(variable_name) se kisi bhi variable ka data type check kar sakte hain.

print(type(x)) # <class 'int'>

print(type(y)) # <class 'float'>

print(type(name)) # <class 'str'>

2. Input aur Output (इनपुट औि आउटपुट)

Python me input() function se user se data le sakte hain aur print() se output show kar sakte hain.

name = input("Enter your name: ")

print("Hello,", name)

Agar kisi bhi input ko number (integer ya float) me convert karna ho to int() ya float() use kar sakte hain:

age = int(input("Enter your age: "))

print("Your age is", age)

3. Operators (ऑपिे टिस)

Operators mathematical ya logical operations perform karne ke liye use hote hain.

Arithmetic Operators:

a = 10

b=5

print(a + b) # Addition: 15

print(a - b) # Subtraction: 5

print(a * b) # Multiplication: 50

print(a / b) # Division: 2.0

print(a % b) # Modulus: 0
print(a ** b) # Exponent: 10^5

print(a // b) # Floor Division: 2

Comparison Operators:

print(a == b) # False

print(a != b) # True

print(a > b) # True

print(a < b) # False

Logical Operators:

x = True

y = False

print(x and y) # False

print(x or y) # True

print(not x) # False

4. Conditional Statements (If-Else)

If-Else ka use decision making ke liye hota hai.

age = int(input("Enter your age: "))

if age >= 18:

print("You can vote")

elif age == 17:

print("You will be eligible next year")

else:

print("You cannot vote")

5. Loops (लूप्स)

Loops ka use repeatative tasks perform karne ke liye hota hai.

For Loop

for i in range(5):

print(i) # 0,1,2,3,4

While Loop
i=0

while i < 5:

print(i)

i += 1

6. Functions (फंक्शन)

Functions code ko reusable aur modular banate hain.

def greet(name):

return "Hello, " + name

print(greet("Amit"))

7. List, Tuple, Dictionary (वलस्ट, टपल, औि वडक्शनिी)

List (Mutable)

fruits = ["Apple", "Banana", "Cherry"]

fruits.append("Mango")

print(fruits)

Tuple (Immutable)

tuple1 = (1, 2, 3)

print(tuple1[0])

Dictionary (Key-Value Pairs)

student = {"name": "Rahul", "age": 20}

print(student["name"])

8. File Handling (फाइल हैंडवलंग)

File handling ka use file read/write karne ke liye hota hai.

File Read

with open("test.txt", "r") as file:

data = file.read()

print(data)
File Write

with open("test.txt", "w") as file:

file.write("Hello, World!")

9. Exception Handling (एिि हैंडवलंग)

try:

a = 10 / 0

except ZeroDivisionError:

print("Cannot divide by zero")

finally:

print("This will always execute")

10. Object-Oriented Programming (OOPs)

class Car:

def __init__(self, brand, model):

self.brand = brand

self.model = model

def display(self):

print(f"Car: {self.brand}, Model: {self.model}")

c1 = Car("Toyota", "Corolla")

c1.display()

Ye Python ka ek Complete Basic Notes hai jo aapko programming sikhnay me madad karega. Aage aur bhi
detail me explore kar sakte hain!

You might also like