-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass1.py
More file actions
39 lines (29 loc) · 791 Bytes
/
Copy pathclass1.py
File metadata and controls
39 lines (29 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 3 13:17:49 2026
@author: salehi
"""
class Book():
def __init__(self,page,name):
self.pages=page
self.name=name
def open(self):
print(f"open the {self.name} book and has {self.pages} page")
'''b1=Book(150,"C Programming")
b1.open()'''
class Darsi(Book):
def __init__(self, reshteh, payeh,page,name):
Book.__init__(self, page, name)
self.reshteh=reshteh
self.payeh=payeh
print(f"{self.reshteh} and {self.payeh}")
d=Darsi("medical", 3,203,'c programming')
d.open()
print(d)
class Car:
def __init__(self, brand):
self.brand = brand
def __str__(self):
return f"Car brand: {self.brand}"
my_car = Car("Toyota")
print(my_car)