Skip to content

Commit 85d9fe2

Browse files
committed
4:51 PM Commit
1 parent 6a6394a commit 85d9fe2

6 files changed

Lines changed: 296 additions & 1 deletion

File tree

AIwithPython/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 🧠 AI with Python
2+
3+
Welcome to **AI with Python** — a beginner-friendly and practical repository that explores how **Artificial Intelligence (AI)** works and how you can build intelligent systems using **Python**.
4+
5+
---
6+
7+
## 🌍 What is Artificial Intelligence (AI)?
8+
9+
**Artificial Intelligence (AI)** is the broad field of computer science focused on creating systems that can **think, learn, and act like humans**.
10+
AI enables machines to perform tasks that normally require human intelligence — such as reasoning, understanding language, recognizing patterns, solving problems, and making decisions.
11+
12+
Examples:
13+
- Chatbots that understand natural language
14+
- Recommendation systems (Netflix, Spotify, YouTube)
15+
- Autonomous vehicles
16+
- Image recognition and voice assistants
17+
18+
---
19+
20+
## 🤖 AI vs ML vs DL vs GenAI
21+
22+
| Concept | Description | Example |
23+
|----------|--------------|----------|
24+
| **AI (Artificial Intelligence)** | The *umbrella field* — aims to create intelligent systems that can simulate human-like thinking and decision-making. | A self-driving car deciding when to stop or go. |
25+
| **ML (Machine Learning)** | A **subset of AI** focused on teaching machines to learn from data without being explicitly programmed. | A spam filter that improves as it processes more emails. |
26+
| **DL (Deep Learning)** | A **subset of ML** that uses **neural networks with many layers** to automatically learn complex features from data. | Facial recognition or voice assistants like Siri. |
27+
| **GenAI (Generative AI)** | A **type of AI model** (often based on DL) that can **generate new content** — text, images, music, or code — similar to what humans create. | ChatGPT, DALL·E, or Stable Diffusion. |
28+
29+
**Hierarchy Visualization:**
30+
31+
AI
32+
├── Machine Learning (ML)
33+
│ ├── Deep Learning (DL)
34+
│ │ └── Generative AI (GenAI)
35+
36+
37+
---
38+
39+
## 🐍 Why Python for AI?
40+
41+
Python is the most popular language for AI and ML because it is:
42+
- Easy to learn and read
43+
- Supported by a wide ecosystem of powerful libraries:
44+
- **NumPy**, **Pandas** → Data handling
45+
- **Matplotlib**, **Seaborn** → Visualization
46+
- **Scikit-learn** → Machine Learning
47+
- **TensorFlow**, **PyTorch**, **Keras** → Deep Learning
48+
- **Transformers**, **LangChain** → Generative AI
49+
50+
---
51+
52+
## 📘 Topics Covered
53+
54+
This repository will guide you through:
55+
1. **Python Basics for AI** – Variables, data types, loops, functions
56+
2. **Data Science Foundations** – Numpy, Pandas, and data preprocessing
57+
3. **Machine Learning** – Supervised and Unsupervised learning
58+
4. **Deep Learning** – Neural networks and CNNs
59+
5. **Generative AI** – Transformers, LLMs, and text/image generation
60+
6. **AI Deployment** – Using AWS SageMaker and APIs
61+
62+
---
63+
64+
## 🚀 Getting Started
65+

Advanced_Python/PythonOOP.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#OOP Python
2+
3+
'''
4+
Object Oriented Programming is a fundamental concept in Python,
5+
empowering developers to build modular, maintainable and scalable applications.
6+
7+
OOP is a way of organizing code that uses objects and classes to represent
8+
real-world entities and their behavior. In OOP, object has attributes thing
9+
that has specific data and can perform certain actions using methods.
10+
11+
'''
12+
13+
class Dog:
14+
species = "Canine" # Class attribute
15+
16+
def __init__(self, name, age):
17+
self.name = name # Instance attribute
18+
self.age = age # Instance attribute
19+
20+
# Creating an object of the Dog class
21+
dog1 = Dog("Buddy", 3)
22+
23+
print(dog1.name)
24+
print(dog1.species)
25+
26+
27+
#Encapsulation example
28+
class Dog:
29+
def __init__(self, name, breed, age):
30+
self.name = name # Public attribute
31+
self._breed = breed # Protected attribute
32+
self.__age = age # Private attribute
33+
34+
# Public method
35+
def get_info(self):
36+
return f"Name: {self.name}, Breed: {self._breed}, Age: {self.__age}"
37+
38+
# Getter and Setter for private attribute
39+
def get_age(self):
40+
return self.__age
41+
42+
def set_age(self, age):
43+
if age > 0:
44+
self.__age = age
45+
else:
46+
print("Invalid age!")
47+
48+
# Example Usage
49+
dog = Dog("Buddy", "Labrador", 3)
50+
51+
# Accessing public member
52+
print(dog.name) # Accessible
53+
54+
# Accessing protected member
55+
print(dog._breed) # Accessible but discouraged outside the class
56+
57+
# Accessing private member using getter
58+
print(dog.get_age())
59+
60+
# Modifying private member using setter
61+
dog.set_age(5)
62+
print(dog.get_info())
63+
64+
65+
#Inheritance example
66+
class Animal:
67+
def speak(self):
68+
return "Animal speaks"
69+
class Dog(Animal):
70+
def speak(self):
71+
return "Woof!"
72+
class Cat(Animal):
73+
def speak(self):
74+
return "Meow!"
75+
76+
dog = Dog()
77+
cat = Cat()
78+
print(dog.speak()) # Output: Woof!
79+
print(cat.speak()) # Output: Meow!
80+
81+
82+
# Method Overriding
83+
# We start with a base class and then a subclass that "overrides" the speak method.
84+
class Animal:
85+
def speak(self):
86+
return "I am an animal."
87+
88+
class Dog(Animal):
89+
def speak(self):
90+
return "Woof!"
91+
92+
print(Dog().speak())
93+
94+
# 2 Duck Typing
95+
class Cat:
96+
def speak(self):
97+
return "Meow!"
98+
99+
def make_animal_speak(animal):
100+
# This function works for both Dog and Cat because they both have a 'speak' method.
101+
return animal.speak()
102+
103+
print(make_animal_speak(Cat()))
104+
print(make_animal_speak(Dog()))
105+
106+
# 3 Operator Overloading
107+
# We create a simple class that customizes the '+' operator.
108+
class Vector:
109+
def __init__(self, x, y):
110+
self.x = x
111+
self.y = y
112+
113+
def __add__(self, other):
114+
# This special method defines the behavior of the '+' operator.
115+
return Vector(self.x + other.x, self.y + other.y)
116+
117+
def __repr__(self):
118+
return f"Vector({self.x}, {self.y})"
119+
120+
v1 = Vector(2, 3)
121+
v2 = Vector(4, 5)
122+
v3 = v1 + v2
123+
124+
print(v3)

Data_Structure/PythonArray.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#Python Arrays
2+
import array as arr
3+
a = arr.array('i', [1, 2, 3])
4+
5+
# accessing First Araay
6+
print(a[0])
7+
8+
# adding element to array
9+
a.append(5)
10+
print(a)
11+
a = [1, "Hello", [3.14, "world"]]
12+
a.append(2) # Add an integer to the end
13+
print(a)
14+
15+
a = arr.array('i', [1, 2, 3, 1, 5])
16+
17+
# remove first occurance of 1
18+
a.remove(1)
19+
print(a)
20+
21+
# remove item at index 2
22+
a.pop(2)
23+
print(a)
24+
25+
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
26+
b = arr.array('i', a)
27+
28+
res = a[3:8]
29+
print(res)
30+
31+
res = a[5:]
32+
print(res)
33+
34+
res = a[:]
35+
print(res)
36+
37+
import numpy as np
38+
a = np.array([1, 2, 3, 4])
39+
40+
# Element-wise operations
41+
print(a * 2)
42+
43+
# Multi-dimensional array
44+
res = np.array([[1, 2], [3, 4]])
45+
print(res * 2)
46+
47+
import array
48+
a = array.array('i', [1, 2, 3, 1, 2, 5])
49+
50+
# update item at index 2
51+
a[2] = 6
52+
print(a)
53+
54+
# update item at index 4
55+
a[4] = 8
56+
print(a)
57+
58+
import array
59+
a = array.array('i', [1, 2, 3, 4, 5])
60+
61+
a.reverse()
62+
print(*a)

Data_Structure/PythonList.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Python Lists
2+
3+
a = [1, 2, 3, 4, 5] # List of integers
4+
b = ['apple', 'banana', 'cherry'] # List of strings
5+
c = [1, 'hello', 3.14, True] # Mixed data types
6+
7+
print(a)
8+
print(b)
9+
print(c)
10+
11+
#List construction using list()
12+
a = list((1, 2, 3, 'apple', 4.5))
13+
print(a)
14+
15+
b = list("GFG")
16+
print(b)
17+
18+
a = [2] * 5
19+
b = [0] * 7
20+
21+
print(a)
22+
print(b)
23+
24+
a = [10, 20, 30, 40, 50]
25+
print(a[0])
26+
print(a[-1])
27+
print(a[1:4]) # elements from index 1 to 3
28+
29+
matrix = [ [1, 2, 3],
30+
[4, 5, 6],
31+
[7, 8, 9] ]
32+
33+
print(matrix[1][2])
34+
35+
squares = [x**2 for x in range(1, 6)]
36+
print(squares)

Fundamentals/LoopStatements.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,10 @@
6161
if i % 2 == 0:
6262
print("Skipping even number i =", i)
6363
continue
64-
print("Current odd i:", i)
64+
print("Current odd i:", i)
65+
66+
67+
list1 = [1, 2, 3]
68+
69+
for item in list1:
70+
print("Item in list1:", item)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This repo includes:
1111
- Exercises and practice problems
1212
- Notes on functions, loops, data structures, and OOP
1313
- Mini projects for hands-on learning
14+
- A.I and M.L using python
1415

1516
It serves as both a **personal study log** and a **reference** for anyone learning Python basics.
1617

@@ -24,6 +25,7 @@ It serves as both a **personal study log** and a **reference** for anyone learni
2425
- Lists, Tuples, Sets, and Dictionaries
2526
- File Handling and Exception Management
2627
- Basic Object-Oriented Programming (OOP) Concepts
28+
- Artificial Intelligence and Machine Learning
2729

2830
---
2931

0 commit comments

Comments
 (0)