Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0321db7

Browse files
author
hussienalrubaye
committed
OOP
1 parent8a1caa3 commit0321db7

File tree

8 files changed

+265
-142
lines changed

8 files changed

+265
-142
lines changed

‎.idea/workspace.xml‎

Lines changed: 127 additions & 132 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎OOPBasicClass.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
classCar:
3+
defGetOwner(self):
4+
print("Owner is ",self._Name)
5+
defSetOwner(self,Name):
6+
self._Name=Name
7+
8+
9+
10+
defmain():
11+
mycar=Car()
12+
mycar.SetOwner("Hussein Alrubaye")
13+
mycar.GetOwner()
14+
Jencar=Car()
15+
Jencar.SetOwner("Jen Alrubaye")
16+
Jencar.GetOwner()
17+
18+
19+
20+
if__name__=='__main__':main()

‎OOPInhertance.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
classOperation:
2+
defSum(self,n1,n2):
3+
SumResult=n1+n2
4+
print("Sum=",SumResult)
5+
defSub(self,n1,n2):
6+
SubResult=n1-n2
7+
print("Sub=",SubResult)
8+
classOperationWithMul(Operation):
9+
10+
defMul(self,n1,n2):
11+
MulResult=n1*n2
12+
print("Mul=",MulResult)
13+
14+
15+
defmain():
16+
#OP=Operation()
17+
#OP.Sub(4,2)
18+
#OP.Sum(10,15)
19+
OpMul=OperationWithMul();
20+
OpMul.Sub(4,2)
21+
OpMul.Sum(10,15)
22+
OpMul.Mul(10,2)
23+
24+
25+
26+
27+
28+
if__name__=='__main__':main()

‎OOPKwarges.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
classCar:
3+
def__init__(self,**kwargs):
4+
self.Data=kwargs
5+
defGetOwner(self):
6+
print("Owner Name ",self.Data["Name"])
7+
print("Car Model ",self.Data["Model"])
8+
print("Year ",self.Data["Year"])
9+
defSet_Model(self,Model):
10+
self.Data["Model"]=Model
11+
defGet_Model(self):
12+
print("Car Model ",self.Data["Model"])
13+
14+
15+
16+
17+
defmain():
18+
mycar=Car(Name="Hussein Alrubaye",Model="camer 2015",Year=2015)
19+
mycar.GetOwner()
20+
Jencar=Car(Name="Jen Alrubaye",Model="sony x",Year=2015)
21+
Jencar.GetOwner()
22+
#jen model set
23+
Jencar.Set_Model("2016")
24+
Jencar.Get_Model()
25+
26+
27+
28+
if__name__=='__main__':main()

‎OOPOverride.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
classOperation:
2+
defSum(self,n1,n2):
3+
SumResult=n1+n2
4+
print("Sum=",SumResult)
5+
defSub(self,n1,n2):
6+
SubResult=n1-n2
7+
print("Sub=",SubResult)
8+
classOperationWithMul(Operation):
9+
10+
defMul(self,n1,n2):
11+
MulResult=n1*n2
12+
print("Mul=",MulResult)
13+
defSub(self,n1,n2):
14+
super().Sub(n1,n2)
15+
#SubResult=n1-n2+5
16+
#print("Sub=",SubResult)
17+
18+
19+
defmain():
20+
#OP=Operation()
21+
#OP.Sub(4,2)
22+
#OP.Sum(10,15)
23+
OpMul=OperationWithMul();
24+
OpMul.Sub(4,2)
25+
OpMul.Sum(10,15)
26+
OpMul.Mul(10,2)
27+
28+
29+
30+
31+
32+
if__name__=='__main__':main()

‎OOPconstructors.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
classCar:
3+
def__init__(self,Name):
4+
self._Name=Name
5+
defGetOwner(self):
6+
print("Owner is ",self._Name)
7+
8+
9+
10+
11+
defmain():
12+
mycar=Car("Hussein Alrubaye")
13+
mycar.GetOwner()
14+
Jencar=Car("Jen Alrubaye")
15+
Jencar.GetOwner()
16+
17+
18+
19+
if__name__=='__main__':main()

‎main.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ def main():
88

99

1010

11+
1112
if__name__=='__main__':main()

‎snaped.txt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
x=1
2-
x="hi" if x==1 else "why"
3-
fo = open("foo.txt", "a") #r write a append
4-
fo.write( "Python is a great language.\nYeah its great!!\n")
5-
fo.close()
6-
r = open("foo.txt", "r")
7-
# read=r.read(102033)
8-
for s in r:
9-
print(s)
10-
r.close()
1+
db=sqlite3.connect("test.db")
2+
db.row_factory = sqlite3.Row
3+
db.execute("create table if not exists Admin(name text,age int)")
4+
db.execute("insert into Admin (name,age) values (?, ?)",("hussein",27))
5+
#db.execute('insert into Admin (name, age) values (?, ?)', (row['t1'], row['i1']))
6+
print("hello from python")
7+
print("next line execute")
8+
cursor=db.execute("select * from Admin")
9+
for row in cursor:
10+
print(' {}: {}'.format(row['name'], row['age']))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp