-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlab02.py
104 lines (72 loc) · 2.05 KB
/
lab02.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# import lab03
class IntegerNum:
'class attribute goes here'
def __init__(self,p1):
self.number = p1
def doubleNum(self):
return self.number*2
def squareNum(self):
return self.number**2
def pow(self,k):
return self.number**k
def abs(self):
if self.number > 0:
return self.number
elif self.number < 0:
return -self.number
else:
return 0
class Circle:
'class attribute goes here'
pi = 3.14
valami = 0
def __init__(self,r):
self.radius = IntegerNum(r)
self.name = 'Kör'
self.diameter = IntegerNum(2*r)
def __str__(self):
return "This circle has radius: {} and its area: {}".format(self.radius.number,self.getArea())
def getArea(self):
return self.radius.squareNum()*self.pi
def getPerimeter(self):
return self.radius.doubleNum()*self.pi
class MyString:
def __init__(self):
self.str = ""
def getString(self):
self.str = input('Give me a string:')
def printString(self):
print(self.str.upper())
class SpecialElementsOfList:
def __init__(self,ls):
self.list = ls
self.__length = len(ls)
def getSumZeroSubLists(self):
resLs = []
tmpLs = []
for i in range(0,self.__length):
for j in range(i+1,self.__length):
for k in range(j+1,self.__length):
tmpLs.append(self.list[i])
tmpLs.append(self.list[j])
tmpLs.append(self.list[k])
if sum(tmpLs) == 0:
resLs.append(tmpLs)
tmpLs = []
return resLs
#MAIN
c1 = Circle(5)
c2 = Circle(7)
print(c1.__str__())
print(c2.__str__())
c1.radius=IntegerNum(27)
print(c1.getArea())
print(c2.getPerimeter())
print(dir(c2))
str = 'english'
print(str.upper())
specLS = SpecialElementsOfList([-25, -10, -7, -3, 2, 4, 8, 10])
print(specLS.list)
print(specLS.getSumZeroSubLists())
# t1 = lab03.Triangle(3,4,5)
# print(t1)