abobaker09

oop 2 in python

Oct 9th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #في بايثون ٣ يكتب الكلاس بدون اقواس وتسخدم الاقواس ف حالة الوراثة
  2. class b :
  3.     def s(self,x,y):#لابد من كتابة كلمة self
  4.         return x+y
  5. bb=b()#هنا اشتقينا كائن من الكلاس
  6. print(bb.s(8,9))
  7. class v:
  8.     def f(self):
  9.         x=input("enter the name \n")
  10.         y=int(input("enter the age\n"))
  11.         if y >0 and y <20:
  12.             print( x, "your boy")
  13.         elif y>20 and y<30:
  14.             print (x,"your sham")
  15.         elif y>30 and y<40:
  16.             print(x,"you old")
  17.         else:
  18.             print("not")
  19. dd=v()
  20. dd.f()
Add Comment
Please, Sign In to add comment