-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
131 lines (97 loc) · 1.91 KB
/
main.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import math
class Animal:
_weigh = 4
def __init__(self):
print("Animal object created")
def move(self):
print("Animal moved")
def get_weight(self):
return self._weigh
def set_weigh(self, weigh):
if weigh>0:
self._weigh=weigh
else:
print("Ne pravilnoe znachenie vesa")
def __del__(self):
print("Animal object deleted!")
class Dog(Animal):
def __init__(self):
print("Dog object created")
def voice(self):
print("Gav gav gav!!!")
def __del__(self):
print("Dog object deleted")
class Cat(Animal):
def __init__(self):
print("Cat object created")
def voice(self):
print("Meov meov meov!!!")
def __del__(self):
print("Cat object deleted")
def speak( a):
a.voice()
d=Dog()
c=Cat()
speak(d)
speak(c)
def div(a, b):
try:
return a/b
except ArithmeticError:
print("Zero division error")
except TypeError:
print("Type errro")
finally:
print("Chtoto delat vne zavisimosti ot rezultata!")
dr=div(4, 0)
print("Div result: ", dr)
# d.move()
# d._weigh=43
#
# d.voice()
# b = Animal()
# b.move()
# b.set_weigh(-12)
# print ("Animal weight is: ",b.get_weight())
# int a=7
#
# def is_simple(a):
# for i in range(2, math.isqrt(a)+1):
# if a%i==0:
# return False
# return True
#
#
# for i in range(1,100):
# if is_simple(i):
# print(i, "-prostoe chislo")
# if is_simple(127):
# print("Chislo prostoe")
# else:
# print("Chislo sostavnoe")
# def my_max(a,b):
# if a>b:
# return a
# else:
# return b
#
#
#
# c=my_max(3,12)
# print(c)
# ar=[5,"Hello",5,6,3,12]
# print(ar[4])
#
# a=15
# b=7
# for i in range(3,100, 3):
# print(i)
# if i%3==0:
# print(i)
# if a>b:
# max=a
# else:
# max=b
# print("Max: ",max)
# c=a+b
# print("Summa: ", c)