8000 complete oop · AriFullah3202/basic-python@950d16d · GitHub
[go: up one dir, main page]

Skip to content

Commit 950d16d

Browse files
committed
complete oop
1 parent c39c9c8 commit 950d16d

File tree

8 files changed

+184
-1
lines changed

8 files changed

+184
-1
lines changed

CarClass.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Car:
2+
# constractor create kora
3+
# ekhane ekta parameter jar name holo name
4+
def __init__(self , name , price , color):
5+
print("this is one parameterize constructor is " , name)
6+
self.price = price
7+
self.color = color
8+
self.name = name
9+
# eta method
10+
def details(self):
11+
print('Car name' , self.name , self.price , self.color)
12+
def color(self):
13+
print("this is color method")
14+
15+
car1 = Car("bm" , "333" , 'blue')
16+
17+
car2 = Car('bw' , '3383' , 'green')
18+
car2.details()
19+
car1.details()
20+

CrudOperation.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
course = []
2+
while True:
3+
createlist = input("Enter choice ... what do you want to learn for course ? / add / read / update / delete / exit" , )
4+
if createlist == 'exit' :
5+
print('you exit from the course')
6+
break;
7+
elif createlist == 'read' :
8+
if len(course) == 0:
9+
print("you are not enrolled yet . please enroll the course")
10+
else:
11+
print("continue the course" , course)
12+
13+
elif createlist == 'add':
14+
new_course = input("Enter the name of the course you want to add: ")
15+
course.append(new_course)
16+
print("Course added successfully!")
17+
18+
elif createlist == 'update':
19+
if len(course) == 0:
20+
print("You are not enrolled in any courses yet. Please add a course first.")
21+
else:
22+
index = int(input("Enter the index of the course you want to update: "))
23+
if index < 0 or index >= len(course):
24+
print("Invalid index.")
25+
else:
26+
new_name = input("Enter the new name for the course: ")
27+
course[index] = new_name
28+
print("Course updated successfully!")
29+
30+
elif createlist == 'delete':
31+
if len(course) == 0:
32+
print("You are not enrolled in any courses yet. Please add a course first.")
33+
else:
34+
index = int(input("Enter the index of the course you want to delete: "))
35+
if index < 0 or index >= len(course):
36+
print("Invalid index.")
37+
else:
38+
deleted_course = course.pop(index)
39+
print(f"Course '{deleted_course}' deleted successfully!")
40+
41+
else:
42+
print("Incorrect input. Please try again.")

Function.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# python function def keyword diye
2+
3+
# def keyword eta dite hbe
4+
# then methon name
5+
# first bracket
6+
# then :
7+
# then body
8+
9+
def hello() :
10+
print("hello world")
11+
hello()
12+
# with parameter
13+
def hello(name) :
14+
print(name)
15+
hello("Arif")
16+
# with return type , eta java deklam na
17+
def cacutation (x, y):
18+
d = x+y
19+
e = x-y
20+
f= x*y
21+
g = x/y
22+
return d , e , f, g
23+
sum , sub , mul , div = cacutation(20 , 4)
24+
print("sum :" , sum , "sub" , sub , "mul" , mul , "div" , div)

OOP.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# oop vs procedural programming
2+
# java hocche oop
3+
# c hocche procedural programming
4+
5+

dictionary.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@
88
}
99
print(firstdict) # {'name': 'Arif', 'id': 222, 'year': 2333}
1010
print(type(firstdict)) # <class 'dict'>
11+
# dictionary er key k access korte chaile
12+
x = firstdict.keys() # eta key gulo print korbe
13+
print(x)
14+
# dictionary value
15+
y = firstdict.values() # sob value print korbe
16+
print(y)
17+
x = firstdict['name'] # etar value print korbe
18+
print(x)
19+
y = firstdict.get('Dl')
20+
print(y)
21+
# Adding item
22+
# Removing item
23+
# item add
24+
firstdict['Da'] = 30 # firsdict er vitor e ei item ta add hobe
25+
# update method
26+
firstdict.update({'year' : 2032}) #year er moddhe value change holo
27+
print(firstdict)
28+
# remove methon
29+
firstdict.pop()
1130

1231

1332

inheritanceCar.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class A :
2+
def detail(self):
3+
print("this is details")
4+
def details(self):
5+
print("this is details method")
6+
7+
class B(A) :
8+
def chd(self):
9+
print('this is child')
10+
def chd2(self):
11+
print("this si child2")
12+
a = A()
13+
a.details()
14+
b = B()
15+
b.details()
16+
b.detail()
17+
b.chd()

set.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,37 @@
77
print(firstset) # {True, 38.8, 88, 'aiquest', 383}
88
print(type(firstset)) # set output --- <class 'dict'>
99

10+
# set hocche unique , duplicate remove kore dibe
11+
# Access item korte for loop use korte hbe
12+
# discard diye remove kore
13+
# set Union | ei symbol use kori . ekhane sob value nibe
14+
# set intersection hocche commnon value nibe, duplicate remove korbe
15+
16+
duration = {2, 3, 4, 45, 3, 3 ,4}
17+
print(type(duration))
18+
#remove duplicate automatic
19+
print("remove duplicte automatic " , duration) # 2, 3, 4, 45
20+
# access item 1st wa y
21+
# set access korte for loop use korte hbe
22+
for x in duration :
23+
print("acces item" , x)
24+
25+
# 2nd way to access
26+
print(1001 in duration) # false
27+
28+
# add item
29+
duration.add(99)
30+
print("add item" , duration) # {2, 99, 3, 4, 45} # buji nai
31+
# discard
32+
duration.discard(3333) # buji nai
33+
print('discard ' , duration)
34+
35+
# del keyword
36+
#del duration
37+
print('delete set' , duration) # bujij nai # ekane exception dibe
38+
39+
# set union
40+
success = {3, 3, 2, 4}
41+
print("set union" , duration | success)
42+
# set intersection
43+
print('set intersection' , duration & success)

tuple.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,26 @@
22
# এবং শুরুতে এবং শেষে first bracket থাকে ।
33
firsttuple = ('ai' , 33, "idid" , 8 , True )
44
print(firsttuple) # ('ai', 33, 'idid', 8, True)
5-
print(type(firsttuple)) # <class 'tuple'>
5+
print(type(firsttuple)) # <class 'tuple'>
6+
details = ('create', 'read' , 'update' , 'delete', 30, 84, 84, )
7+
# tuple hocche immutable object , list hocche mutable
8+
print(type(details))
9+
print('Access item range' , details[2])
10+
print("access the range :" , details[:3])
11+
print("Aceess the range " , details[3:])
12+
#update
13+
# tuple k amra change korte pari na
14+
details[2] = "Dajago" # eta exception dibe
15+
print('update item' , details);
16+
# eijonno amra list convert korbo
17+
cd = list(details) #list e convert kore tarpor data change kore abar amar tuple korlam
18+
cd[2] = "dajango"
19+
details = tuple(cd)
20+
print("update item" , details) # update
21+
#Add item
22+
cd = list(details) # list e convert
23+
cd.append('python')# add item
24+
25+
#remove item
26+
cd = list(details)
27+
cd.remove("python")

0 commit comments

Comments
 (0)
0