Python Programming- A Complete Beginner's Guide
Python Programming- A Complete Beginner's Guide
Table of Contents
1. Introduction to Python
2. Getting Started
3. Basic Python Concepts
4. Data Structures
5. Control Flow
6. Functions
7. Object-Oriented Programming
8. Real-World Applications
9. Next Steps
1. Introduction to Python
What is Python?
2. Getting Started
Installation
1. Visit python.org
2. Download latest version (3.x recommended)
3. Install with "Add Python to PATH" option checked
4. Verify installation: Open terminal/command prompt and type `python --version`
Development Environment
```python
# Numbers
age = 25 # integer
height = 5.9 # float
complex_num = 3 + 4j # complex
# Strings
name = "John"
message = 'Hello, World!'
# Boolean
is_student = True
is_working = False
```
Basic Operations
```python
# Arithmetic
x = 10
y=3
print(x + y) # Addition: 13
print(x - y) # Subtraction: 7
print(x * y) # Multiplication: 30
print(x / y) # Division: 3.333...
print(x // y) # Floor Division: 3
print(x % y) # Modulus: 1
print(x ** y) # Exponentiation: 1000
# String Operations
first = "Hello"
last = "World"
full = first + " " + last # Concatenation
print(full * 3) # Repetition
```
4. Data Structures
Lists
```python
fruits = ["apple", "banana", "orange"]
fruits.append("grape") # Add item
fruits.remove("banana") # Remove item
print(fruits[0]) # Access item
print(fruits[-1]) # Last item
print(fruits[1:3]) # Slicing
```
Dictionaries
```python
person = {
"name": "John",
"age": 30,
"city": "New York"
}
print(person["name"]) # Access value
person["email"] = "john@example.com" # Add key-value
```
```python
# Tuple (immutable)
coordinates = (10, 20)
5. Control Flow
Conditional Statements
```python
age = 18
if age >= 18:
print("Adult")
elif age >= 13:
print("Teenager")
else:
print("Child")
```
### Loops
```python
# For loop
for i in range(5):
print(i)
# While loop
count = 0
while count < 5:
print(count)
count += 1
```
6. Functions
message = greet("Alice")
print(message)
Default parameters
7. Object-Oriented Programming
```python
class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model
def display_info(self):
return f"{self.brand} {self.model}"
8. Real-World Applications
url = "https://example.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
```
```python
import pandas as pd
Basic analysis
average = data['column'].mean()
maximum = data['column'].max()
```
Automation Example
python
import os
9. Next Steps
Learning Resources :
Conclusion
Remember: Practice is key to mastering Python. Start with small projects and gradually increase
complexity. Join Python communities and participate in discussions.